A Laravel package for generating modular API applications.
Install via Composer:
composer require atilla/submodulesThe package will automatically register its service provider.
Publish the configuration file:
php artisan vendor:publish --tag=submodules-configThis will create config/submodules.php where you can customize:
- Modules path
- Base namespace
- Directory structure
- Files to generate
- Route configurations
- View settings
php artisan make:module BlogThis will generate a new module with the following structure:
src/SubModules/Blog/
├── Controllers/
│ └── BlogController.php
├── Models/
│ └── Blog.php
└── Providers/
└── BlogServiceProvider.php
... etc
--force- Overwrite existing module
Each module includes:
- ServiceProvider
- Controller with CRUD + API actions
- Eloquent Model
- Basic routing configuration
Publish the stub files to customize the generated code:
php artisan vendor:publish --tag=module-generator-stubsKey settings in config/submodules.php:
return [
'submodules_path' => 'src/SubModules',
'namespace' => 'SubModules',
'structure' => [
'Controllers',
'Models',
'Providers',
// More to come...
],
'files' => [
'service_provider' => true,
'controller' => true,
'model' => true,
// Configure which files to generate...
]
];- PHP 8.1+
- Laravel 9.0+