PHPackages                             jackwander/laravel-module-maker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jackwander/laravel-module-maker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jackwander/laravel-module-maker
===============================

A zero-config custom module creator for Laravel 11 projects.

2.7.0(today)1395↑156.3%MITPHPPHP ^8.2

Since Aug 29Pushed 3w ago1 watchersCompare

[ Source](https://github.com/jackwander/Laravel-Module-Maker)[ Packagist](https://packagist.org/packages/jackwander/laravel-module-maker)[ GitHub Sponsors](https://github.com/jackwander)[ Fund](https://ko-fi.com/jackwander)[ RSS](/packages/jackwander-laravel-module-maker/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (15)Versions (31)Used By (0)

Laravel Custom Module Creator
=============================

[](#laravel-custom-module-creator)

This package provides a robust, modular architecture for Laravel applications. Designed for consistency and maintainability, it allows you to build features in isolation within the `app/Modules` directory.

> **🚀 Zero-Config:** As of v2.0.0, this package automatically handles PSR-4 autoloading, Service Provider registration, and API route discovery. No manual `composer.json` or `app.php` edits are required.

---

📋 Requirements
--------------

[](#-requirements)

RequirementSupported Versions**PHP**`^8.2`**Laravel**`^11.0 | ^12.0 | ^13.0`---

📦 Installation
--------------

[](#-installation)

```
composer require jackwander/laravel-module-maker
```

---

⚙️ Configuration Reference
--------------------------

[](#️-configuration-reference)

To customize the package behavior, publish the configuration file:

```
php artisan vendor:publish --tag="config"
```

The configuration file (`config/module-maker.php`) allows you to define where your modules are stored and which base classes they should inherit from.

### 📄 Default Configuration

[](#-default-configuration)

```
return [
    /*
    |--------------------------------------------------------------------------
    | Package Paths & Namespaces
    |--------------------------------------------------------------------------
    */
    'paths' => [
        'modules'    => base_path('app/Modules'), // Root folder for modules
        'api_prefix' => 'api/v1',                 // URL prefix for generated routes
    ],

    'namespaces' => [
        'root' => 'App\\Modules',                 // Base namespace for modules
    ],

    /*
    |--------------------------------------------------------------------------
    | Base Classes
    |--------------------------------------------------------------------------
    */
    'base_classes' => [
        'service'        => \Jackwander\ModuleMaker\Base\BaseService::class,
        'api_controller' => \Jackwander\ModuleMaker\Base\BaseApiController::class,
        'model'          => \Jackwander\ModuleMaker\Base\BaseModel::class,
    ]
];
```

### 🛠️ Overriding Options

[](#️-overriding-options)

- **`paths.modules`**: If you prefer a different root folder (e.g., `app/Core`), update this and ensures the `namespaces.root` matches your PSR-4 autoloading.
- **`paths.api_prefix`**: Change the versioning or prefix of your API routes (e.g., `api/v2`).
- **`base_classes`**: This defines the parent classes for your generated Services, Controllers, and Models. We recommend using `php artisan jw:init` to automatically set these up as local bridge classes.

---

🏗️ Architecture &amp; Inheritance
---------------------------------

[](#️-architecture--inheritance)

To keep your application maintainable and scalable, this package encourages an **Intermediate Base Class** (Bridge) pattern. This allows you to customize global behavior—like custom response formatting or shared business logic—without ever touching the `vendor/` directory.

```
The Inheritance Chain

```

Your generated modules follow this hierarchy:

**`Vendor Base`** ➜ **`App Core`** ➜ **`Module File`**

1. **Vendor Base:** The raw logic provided by the package inside `ModuleMaker/Base` (Read-only).
2. **App Core:** Your custom bridge where you add project-specific logic (Editable).
3. **Module File:** The specific logic for a feature (e.g., `PersonService`).

---

🚀 Quick Start: Core Initialization
----------------------------------

[](#-quick-start-core-initialization)

To take full control of your application's architecture, we recommend initializing a **Core Module**. This generates local base classes in your project that extend the package's internal logic, allowing you to add global methods that every future module will inherit.

```
php artisan jw:init
```

### What this does:

[](#what-this-does)

1. **Creates Base Classes:** Generates `BaseModel`, `BaseApiController`, and `BaseService` in `app/Modules/Core/`.
2. **Localizes Config:** Automatically updates `config/module-maker.php` to point to these new local classes.
3. **Hierarchy Bridge:** Your local classes extend the vendor classes, giving you the best of both worlds: automatic package updates and full project customization.

### Example: Customizing your Core

[](#example-customizing-your-core)

Once initialized, you can open `app/Modules/Core/BaseService.php` and add project-wide logic:

```
