-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.6] Allow callable array syntax in route definition #24385
Conversation
what is the better navigation, that you can click through to the controller? |
yes, navigating to correct controller from string is bothersome |
Can't you just do that already manually, with about the same number of characters?
|
i guess you can, but in php array is one of the callable syntaxes so I added that |
Nice addition. I've hacked this in for years. |
It should works with code like |
It does not currently. |
Can you implement that? Seems that it could be done on line 47. It will make me very happy, once that I commonly use with |
I think there are two problems with this implementation:
I think these problems as well as lack of support of |
I would just add that you can not do : Route::get('/hello-world/{userId}', [
'as' => 'call_hello_world_please',
'uses' => [ Hello::class, 'world' ],
]); So you need to fallback to the string syntax ... 💀
|
This was rejected in #24589 |
This PR will allow defining route actions as arrays
Route::get('smth', [SomeController::class, 'methodName']);
This has no direct benefit code-wise, but enables better navigation in IDE-s.
is_callable
validates that specified class and method exist and onlyis_array
check is needed.