This package extends every Laravel artisan make command with a --module flag, so you can generate models, controllers, migrations, and more directly inside any module. It also scaffolds entire module skeletons in one command and lets you publish and customize the stubs to fit your workflow.
There are many alternative packages for creating module skeletons, but they don't give you much flexibility and are auto-discovered. This package gives you full control over your modules.
Here are a few popular packages:
- nwidart/laravel-modules
- internachi/modular
- joshbrw/laravel-module-installer
- PHP 8.2+
- Laravel 11, 12, or 13
- saeedhosan/module-support
Install via Composer:
composer require saeedhosan/module-consoleAfter creating a module, you need to load it into your application. Here are two ways to do it:
1. Use Composer path repositories (recommended)
Add this to your root composer.json so Composer treats every module as a local package:
"repositories": [
{
"type": "path",
"url": "modules/*",
"options": {
"symlink": true
}
}
]Then require the module like any Composer package:
composer require modules/blogComposer will symlink it and auto-discover the service provider — no manual registration needed.
2. Add the module namespace manually
Register the module's namespace in your composer.json:
"autoload": {
"psr-4": {
"Modules\\Blog\\": "modules/blog/app/"
}
}Then run composer dump-autoload and register the service provider in bootstrap/providers.php:
Modules\Blog\BlogServiceProvider::class,Want to customize the generated files? Publish the stubs and edit them however you like:
php artisan vendor:publish --tag=module-stubsWant to customize how modules are organized? Publish the config file:
php artisan vendor:publish --tag=module-configHere's what you can tweak in config/module.php:
[
'directory' => 'modules', // Where your modules live
'namespace' => 'Modules', // The root namespace for modules
'lowercase' => true, // Normalize module names to lowercase
'vendor' => 'modules', // Vendor directory for module packages
'view_path' => 'resources/views',
'app_path' => 'app',
]Create your first module:
php artisan make:module blogThis generates a clean module structure based on stubs:
modules/blog/
├── app/
│ └── BlogServiceProvider.php
├── config/
│ └── blog.php
├── database/
│ ├── factories/
│ ├── migrations/
│ └── seeders/
├── resources/
│ └── views/
├── routes/
│ └── web.php
├── tests/
│ └── example.php
├── composer.json
└── README.md
Every Laravel make command works with modules too. Just pass the --module flag:
php artisan make:model Post --module=blog
php artisan make:enum PostStatus --module=blog
php artisan make:controller PostController --module=blog
php artisan make:migration create_posts_table --module=blogThis package supports almost all make:* commands to create something inside a module.
php artisan make:YourMakeCommand YourClassName --module=ModuleNameSee all your modules:
php artisan module:listnpm run test # Everything (lint + types + unit)
npm run test:lint # Code style (Pint)
npm run test:types # Static analysis (PHPStan)
npm run test:unit # Unit tests (Pest)Found a bug or want to add a feature? Pull requests are totally welcome. Just make sure the tests pass before submitting.
Module Console was created by Saeed Hosan under the MIT license.