Introduction
Laravel Modular extends Laravel’s built-inmake:* commands by adding a --module option. This allows you to generate components directly within your modules while maintaining Laravel conventions and using your custom stubs.
Available Make Commands
All standard Laravelmake:* commands support the --module option:
Controllers
Generate controllers with routing and resource options
Models
Create Eloquent models with migrations and factories
Migrations
Generate database migrations in your module
Providers
Create service providers for your module
Commands
Build Artisan console commands
Complete Command List
The following commands all support the--module option:
make:cast- Create a new custom Eloquent cast classmake:channel- Create a new channel classmake:command- Create a new Artisan commandmake:component- Create a new view component classmake:controller- Create a new controller classmake:event- Create a new event classmake:exception- Create a new custom exception classmake:factory- Create a new model factorymake:job- Create a new job classmake:listener- Create a new event listener classmake:mail- Create a new email classmake:middleware- Create a new middleware classmake:migration- Create a new migration filemake:model- Create a new Eloquent model classmake:notification- Create a new notification classmake:observer- Create a new observer classmake:policy- Create a new policy classmake:provider- Create a new service provider classmake:request- Create a new form request classmake:resource- Create a new resource classmake:rule- Create a new validation rulemake:seeder- Create a new seeder classmake:test- Create a new test class
How the —module Option Works
Namespace Resolution
When you use the--module option, components are generated with your module’s namespace instead of the application namespace.
Directory Structure
Components are created in your module’ssrc/ directory following Laravel conventions:
Custom Stubs Support
The--module option works seamlessly with Laravel’s stub customization:
Usage Patterns
Basic Usage
The type of component (controller, model, migration, etc.)
The name of the class to generate
The kebab-case name of your module
With Additional Options
All Laravel command options work with--module:
Examples
Generate Multiple Related Components
Organize by Feature
Module Context
When generating components within a module, the package automatically:- Resolves the correct namespace based on your module configuration
- Creates files in the module directory structure
- Updates imports and references to use module namespaces
- Maintains Laravel conventions for directory organization
The
--module option requires that the module already exists. Create modules using php artisan make:module {name} first.