hesammousavi/laravel-module-creator
Laravel Module Creator is an Artisan-powered package for scaffolding modular Laravel applications. Generate module directories, controllers, models, routes, migrations, and more with simple commands, helping organize large projects into reusable, maintainable modules.
Install the package.
composer require hesammousavi/laravel-module-creator
Laravel's package discovery should register the service provider automatically; if not, add Hesammousavi\LaravelModuleCreator\ModuleCreatorServiceProvider::class to config/app.php.
Publish the config and stubs.
php artisan vendor:publish --provider="Hesammousavi\LaravelModuleCreator\ModuleCreatorServiceProvider"
This gives you config/module-creator.php (module path, namespace, stub locations) and the stub files used to scaffold new code. Read this config file first — it tells you exactly where modules land (typically Modules/ or app/Modules/) and what namespace they get.
Confirm the command surface.
php artisan list | grep -i module
The package exposes scaffolding commands (a make:module-style entry point plus per-artifact generators for controllers, models, migrations, routes). Always run php artisan help <command> before using it in scripts — the flags differ across minor releases.
Your first use case: scaffold a vertical slice. Create one module for a self-contained feature (e.g. Billing) with its controller, model, migration, and route file, then register the module's service provider and load its routes. This is the workflow the package is designed around — you get the directory shell and file skeletons, and you fill in the business logic.
vendor/hesammousavi/laravel-module-creator/src).declare(strict_types=1), your base controller, preferred namespace layout, final classes, etc. This is the highest-leverage way to use the package — it turns "new module" into "new module that already looks like our codebase."ModuleServiceProvider or the package's auto-registration) so adding a module is a directory-add, not a bootstrap edit.database/migrations and seeders. Confirm the module service provider calls $this->loadMigrationsFrom(...) — if it doesn't, you'll need to add that wiring manually or your tables won't be created.composer.json. If the package doesn't register autoloading, add a mapping for the module root and run composer dump-autoload after generating a new module.composer dump-autoload (or add the path to composer.json autoload.psr-4 and dump). This is the #1 first-run error.php artisan config:cache is on, edits to config/module-creator.php are ignored. Run php artisan config:clear after changing module paths or namespaces, and re-cache once you're stable.nwidart/laravel-modules. Both packages want the Modules\ namespace and a Modules/ directory. Do not install both. If you're migrating, uninstall one fully before generating with the other, or you'll get duplicate-provider and duplicate-autoload errors.File::makeDirectory. Use forward slashes in config; absolute paths from a Windows environment can break stub rendering. Also watch for trailing-slash duplication in generated namespaces.config/app.php, bootstrap/providers.php on Laravel 11+, or via a manifest). If routes 404 or migrations don't run, the provider is almost always the culprit.php artisan tinker → config('module-creator')) and check the source in vendor/hesammousavi/laravel-module-creator/src/Commands — with 25 stars, documentation is thin and the code is the source of truth.composer.json and read the changelog on upgrade; command signatures and stub variable names are the most likely break points.app/ as usual.How can I help you explore Laravel packages today?