Support specifying namespace to generate classes in
This both fixes an infinite loop caused when the application namespace is an empty string (as it is in a domain-driven codebase like Winter CMS as there is no "root" namespace for the application) while also adding support for the --in option originally proposed in https://github.com/laravel/framework/pull/48571 by @innocenzi.
This PR takes it a step further to resolve the correct path for real namespaces so that namespaces outside of root namespace (which may or may not actually exist) can also be written to.
Tests are failing because of a byproduct of the ochestra testbench setup, the scaffolded files are being generated inside of vendor/orchestra/testbench-core/laravel/$absolutePathToOrchestraTestBenchCoreLaravel; investigating further
The failing test is passing locally, not sure why and can't rerun it on here.
Not sure I want the namespace selection logic. 🤔 Can we fix the bug without that?
@taylorotwell I know you personally prefer the classic structure, but for people working in other ways, that would be a nice quality of life to avoid fighting the framework! Could you consider it?
@taylorotwell I'm not sure how the infinite loop could be solved without also asking the user for more information on what namespace the class should be generated in. And if you're going to allow that anyways, I'm not sure why we wouldn't just allow it to be passed as an option from the start.
If you have ideas for how the code can better handle the case of an empty root namespace being set that would be appreciated. Do you have any concerns about how the namespace selection logic works? It will only ever prompt the user to provide one when there isn't a root namespace to use and won't change how most people interact with laravel/laravel applications at all.