-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Added backslash before route namespace #1788
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
Conversation
Without backslash Laravel will append namespace to main application namespace and will return an error "Class App\Http\Controllers\Laravel\Cashier\WebhookController does not exist".
No it doesn't. That's not true at all. That will ONLY happen if you wrap things in a namespace group, and the example here is not wrapped in such a group. |
I might be wrong here but I don't have webhook route wrapped in Route::group() so your comment seems to be not true at all to me. All I have at the end of my routes.php is (no group around it): Route::post('stripe/webhook', '\Laravel\Cashier\WebhookController@handleWebhook'); and it works. When I remove the backslash and I try this route via Postman (POST) it gives me an error. |
No, it does. Laravel wraps it in a group when it loads it. |
So there is a group. ;) |
Laravel doesn't magically guess the namespace you see. ;) |
Ok, I don't want to argue here, but to me if we want to have the best framework documentation ever, then we have to add notes in the docs. This is not explained and people might just simply copy&paste Taylor's example and it will not work. Majority of people won't go into Postman to test this route, they will rely on Taylor's example. Thanks anyway, but I don't understand why are we doing things like this, ie. "example in docs is not wrapped in group so there's no backslash" but obviously it will be wrapped up in a group automatically! Weird approach. |
I'm also not "magically guessing" why docs example doesn't work. Your comment is really unnecessary here. |
I wasn't saying that all. I'm saying Laravel can't magically guess the namespace. |
It's only wrapped in a group because the user does that in their route service provider. That's no secret. |
That said, you are correct in saying that copying and pasting this example will often result in error due to oversight of users, so that's probably good enough reason to change it tbh, so thanks for bringing this up. |
Added backslash before route namespace
Without backslash Laravel will append namespace to main application namespace and will return an error "Class App\Http\Controllers\Laravel\Cashier\WebhookController does not exist".