M
Module Maker Docs

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
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

Package Core Vendor Base
Your Control App Core
Feature Level Module File

Configuration & Customization

To take full control of your architecture, publish the config and set up your core layers.

1. Publish Config

Terminal
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:

app/Modules/Core/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.

Example: Full Stack
php artisan jw:make-model CivilStatus --module=Person -a

Available Flags

-m | --migrationGenerate a Migration file.
-s | --serviceGenerate a Service class.
-c | --controllerGenerate a Controller.
-a | --allGenerate 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

Controller
php artisan jw:make-controller CivilStatus --module=Person
Service
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:

app/Modules/
└── 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