-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Add alternative way to provide the namespace via configuration #776
Conversation
Hi, Thanks for your contribution! However, I don't see a use-case for this. In php the namespace should always (or is recommended) match the folder structure. |
@nWidart, there is no way for us to modify the path, your console commands were limited because of their default namespace. You're basically using the Sometimes creating a module or a package you wrapped things up inside an E.g, generate a module called
Please try yourself, your code only bound to these kind of folder structure.
But what if we wanted it to be like this, which is normal for opensource developers and we could separate the package as reusable module for other purpose.
And 1 more thing to note that And the pull request above is backward compatible, it is up to Developers if they want to fully customize the folder structure at all, just like me that I am planning to fully use the modular as package implementation. |
So this is a different issue? The src subfolder is something else, that was addressed in previous issues. We shouldn't use the namespace to dictate the folder structure if we can do it the other way around. |
So any solutions on this? I'm not referring to tha path, but the namespace itself, do we have solutions on this if I will be using the path value as
|
Not really, just recommended to not do it. Though if this PR enables this feature, why not add it indeed, I'll test it out in a bit (the configuration is already pretty big, I don't want to add too many things). |
Tested it and seems to work very well. 👌 About the autoloading do you autoload every module manually, or is there a way to have one autoload line for all modules. "Modules\\Blog\\": "Modules/Blog/src" Could you also add tests for these use-cases please? |
src/Commands/CommandMakeCommand.php
Outdated
return $this->laravel['modules']->config('paths.generator.command.path', 'Console'); | ||
$module = $this->laravel['modules']; | ||
|
||
return ($namespace = $module->config('paths.generator.command.namespace')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why catching this in a namespace
variable? I think you can use ?:
instead. In order to have it fit on one line this can be done:
public function getDefaultNamespace() : string
{
$module = $this->laravel['modules'];
$namespace = $module->config('paths.generator.command.namespace');
return $namespace ?: $module->config('paths.generator.command.path', 'Console');
}
(same for all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy will add unit and some changes on it
Should I add another config (by default it is empty) and if developers would like to modify the value into "src/" then inside |
I didn't understand your last comment, you're updating your PR? |
Forget my last comment, I am just thinking a different approach for the autoload path. |
@nWidart updated |
any updates on the autoload issue, cause right now I had to do this #776 (comment) for every module |
@aimensasi there are things that limits us, since we're using stub/template thing, might be better to request a new feature for it referencing this Pull Request? so we could focus into that issue. |
We could add a third option inside paths.generator.{alias} to have
namespace
When adding parent folder, as part of the
path
, the current behaviour uses thepath
as well as the namespace, there is no way for us to easily provide the namespace, or else we are REQUIRED to extends the commands and modify the laravel module's ConsoleServiceProvider and the booted Provider.What I could suggest is to add a 3rd parameter as
optional
, so there is no breaking change @nWidartExample modules that I have and their structure