-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Can't create module inside modules/ in own folder? #37
Comments
It’s saying that you already have an If you don’t have any existing PHP code within |
Hi, thanks very much for quick reply and assistance @brandonkelly! The autoload is already created by a fresh install of CraftCMS "minimum-stability": "dev",
"prefer-stable": true,
"require": {
"craftcms/cms": "^5.0.0",
"vlucas/phpdotenv": "^5.4.0"
},
"require-dev": {
"craftcms/generator": "^2.0.0",
"yiisoft/yii2-shell": "^2.0.3"
},
"autoload": {
"psr-4": {
"modules\\": "modules/"
}
}, The structure of subfolders is mentioned in the docs, therefore I was confused why the docs don't show an example for it. I just tried with ddev craft make module
Module ID: (kebab-case) my-custom-module
Base module class name: (PascalCase) [Module] MyCustomModule
Module location: modules/mycustommodule
Should the module be loaded during app initialization? (yes|no) [no]:yes
→ Creating modules/mycustommodule/ … ✓
→ Creating modules/mycustommodule/MyCustomModule.php … ✓
→ Updating config/app.php … ✓
✅ Module created!
Is this the correct approach you meant? It would be very helpful to have this in the docs imho - happy to propose a quick PR for it! |
Good point. That's now been removed in the latest version of the composer project: https://github.com/craftcms/craft/releases/tag/5.1.0 |
@mandrasch We meant to remove that default Had that not been there, you would end up with a separate If you’re fine with the current folder structure, then it’s fine to leave it as-is. But if you want to switch to a kebab-cased module folder for your new module, you would need to manually adjust the |
Thanks very much for details @brandonkelly & @timkelty! |
Description
I guess I'm missing something - but it seems not to be possible to create a new module folder inside the
modules/
folder withcraft make module
? 🤔I would like to have this structure:
Steps to reproduce
ddev craft make module
Error:
That directory would conflict with the existing modules\ autoload root (modules\my-custom-module isn’t a valid PHP namespace).
Using
Module location: modules/
works, but then the module has no folder on its own.Thanks in advance!
Additional info
Related docs: https://craftcms.com/docs/5.x/extend/module-guide.html
The text was updated successfully, but these errors were encountered: