Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider if the route() helper should throw if the route does not exist #1731

Closed
caendesilva opened this issue Jun 22, 2024 · 3 comments
Closed

Comments

@caendesilva
Copy link
Member

caendesilva commented Jun 22, 2024

Right now, the route() helper returns null if the route does not exist. This means it can a typo in a Blade file like {{ route('hoem') }} will silently link to the same page (href=""). The DX could then be improved by throwing a helpful exception like in Laravel.

There have been some discussion on this before, IIRC, and we may want this in v2 paired with a deprecation warning for legacy uses.

@caendesilva
Copy link
Member Author

caendesilva commented Jun 28, 2024

This is simple enough to fix by using getOrFail in the function, wondering if we should take more steps to normalize the API, and match to Laravel. I'm not sure if there is ever really a reason to want a null return here, I think if you don't want to catch an exception, it's better to use Routes::exists to check first. See #591 which was closed due to similar motivations

@caendesilva
Copy link
Member Author

Fixed in #1741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant