-
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.3] Replace only the first instance of the app namespace in Generators #15575
Conversation
@themsaid wouldn't it be better to have a |
@srmklive it currently guesses the path using the namespace, which is fine imho. |
@themsaid this not working |
@maki10 so are you saying there is still a problem with this PR or not? |
@maki10 this should never work, you either provide the complete namespace or don't provide a namespace at all and the controller will be created in |
@taylorotwell Yup with |
|
@maki10 no not inside a folder, it'll place it in
|
@themsaid What is that 'place' if is not folder??? |
@maki10 hold on, I'm making edits that may solve your issue. |
@maki10 Taking a deeper look at the codebase, there's no way this can be fixed, the thing is, the root namespace is reserved as it's used to check if you're trying to create using a full path or not. If your class starts with To be able to use the root namespace inside a default path you'll have to provide the full path, e.g.:
But that isn't possible because Laravel would replace all This PR fixes the replace all issue by only replacing the first instance of
But doing So my conclusion is that you need to consider the app namespace as a reserved namespace, if you want to use it then you have to provide a full path and never rely on the default path. |
@themsaid nice to know that, so solution for myself is to provide a full path in order to place my controller in App folder inside Controllers. With this PR is possible to place controller in desire path with full namespace. So +1 for PR |
Currently doing this
php artisan make:controller App\Http\Controllers\App\AppController
creates the controller inapp\Http\Controllers\AppController
, this PR fixes this by replacing only the first instance of the app namespace instead of all instances.