Laravel Custom Module Creator
Build scalable Laravel applications with a clean, modular structure. This package provides a zero-config engine to scaffold features in isolation within the app/Modules directory.
🚀 Zero-Config: PSR-4 autoloading, Service Provider registration, and API route discovery are handled automatically. No manual composer.json edits required.
Requirements
| Requirement | Supported Versions |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 |
Installation
Run the following command in your project root:
composer require jackwander/laravel-module-maker
Architecture & Inheritance
We use an Intermediate Base Class (Bridge) pattern. This allows you to customize global behavior without ever touching the vendor/ directory.
The Inheritance Chain
Configuration & Customization
To take full control of your architecture, publish the config and set up your core layers.
1. Publish Config
php artisan vendor:publish --provider="Jackwander\ModuleMaker\ModuleServiceProvider" --tag="config"
2. Create Your Core Layer
Create bridge classes in app/Modules/Core/. Example BaseService.php:
<?php
namespace App\Modules\Core;
use Jackwander\ModuleMaker\Resources\BaseService as VendorBaseService;
class BaseService extends VendorBaseService
{
public function customGlobalLogic()
{
// Add methods shared by ALL modules here
}
}
3. Register Custom Bases
Update config/module-maker.php to point to your core bridge files:
// config/module-maker.php
return [
'base_classes' => [
'service' => \App\Modules\Core\BaseService::class,
'api_controller' => \App\Modules\Core\BaseApiController::class,
'model' => \App\Modules\Core\BaseModel::class,
]
];
Usage Reference
1. Creating a New Module
Generates the full directory structure, Service Provider, and Routes folder.
php artisan jw:make-module Person
2. The Powerhouse Command
The jw:make-model command scaffolds the entire stack in one go using standard Laravel-style flags.
php artisan jw:make-model CivilStatus --module=Person -a
Available Flags
| -m | --migration | Generate a Migration file. |
| -s | --service | Generate a Service class. |
| -c | --controller | Generate a Controller. |
| -a | --all | Generate All (Full Stack). |
3. Individual Component Generation
Migration
php artisan jw:make-migration add_bio_to_persons --module=Person --table=persons
Seeder
Seeders living inside the module directory make features completely portable.
php artisan jw:make-seeder Status --module=Person
Smart Output: The terminal will provide a code snippet to paste into your DatabaseSeeder.php.
Controller & Service
php artisan jw:make-controller CivilStatus --module=Person
php artisan jw:make-service CivilStatus --module=Person
4. System Verification
Run the health-check to ensure all modules are detected and PSR-4 compliant.
php artisan jw:check
📂 Folder Structure
All modules follow this PSR-4 compliant structure automatically:
└── Person/
├── Controllers/ # Module-specific Controllers
├── Models/ # Eloquent Models
├── Services/ # Business Logic
├── Providers/ # Service Provider (Auto-registered)
├── Database/
│ └── Migrations/
│ └── Seeders/
└── Routes/
└── api.php # Prefix: api/v1/persons