PHPackages                             ixspx/module-generator - 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. [API Development](/categories/api)
4. /
5. ixspx/module-generator

ActiveLibrary[API Development](/categories/api)

ixspx/module-generator
======================

Generate module structure in Laravel

v1.0.2(2mo ago)026↓100%MITPHPPHP ^8.1 || ^8.3

Since Feb 8Pushed 2mo agoCompare

[ Source](https://github.com/saul-paulus/module-generator)[ Packagist](https://packagist.org/packages/ixspx/module-generator)[ RSS](/packages/ixspx-module-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

Module-Generator
================

[](#module-generator)

[![PHP Version](https://camo.githubusercontent.com/8777f9860b5e22f70cf49064b7ca2b38beaf8028faca74221106b56b5c741748/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2533453d382e312d627269676874677265656e)](https://www.php.net/)[![License](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

### *Module-Generator in Laravel*

[](#module-generator-in-laravel)

Laravel Module Generator with layered architecture: Model, Repository, Service, Controller, Provider. Generate a complete module structure in Laravel, including:

- Model
- Repositories/Repository + Interface
- Service
- Controller
- Service Provider

🏗 Architecture Overview
-----------------------

[](#-architecture-overview)

### Generate Module

[](#generate-module)

Generated modules follow a layered service–repository architecture:

```
ModuleName/
├── Models/
│   └── ModuleName.php
│
├── Repositories/
│   ├── Interfaces/
│   │   └── ModuleName/
│   │       └── ModuleNameRepositoryInterface.php
│   └── Repository/
│       └── ModuleName/
│           └── ModuleNameRepository.php
│
├── Services/
│   └── ModuleName/
│       └── ModuleNameService.php
│
├── Http/
│   └── Controllers/
│       └── ModuleName/
│           └── ModuleNameController.php
│
└── Providers/
    └── ModuleNameServiceProvider.php

```

### Generate Standard API

[](#generate-standard-api)

This package provides a standardized API foundation for Laravel applications by implementing a Centralized API Response &amp; Exception Handling Pattern. All HTTP responses are forced into a unified JSON format, and all exceptions are handled in a single, centralized layer, ensuring consistency across the entire application. High-level flow

```
Exceptions → Middleware / Exception Handler → Global API Response

```

#### ✨ Key Features

[](#-key-features)

- ✅ Unified JSON response structure
- ✅ Centralized exception handling
- ✅ Opinionated API contract (consistent success &amp; error responses)
- ✅ Middleware-based response enforcement
- ✅ Framework-agnostic business logic (HTTP-agnostic services)
- ✅ Suitable for packages, microservices, and large-scale APIs

🧠 Architectural Principles
--------------------------

[](#-architectural-principles)

This package follows Clean Architecture–inspired layering, where each layer has a single and well-defined responsibility.

1. Model Represents the database table (Eloquent ORM).

    - ❌ No business logic
    - ❌ No complex queries
2. Repository + Interface Encapsulates all data access logic and abstracts the persistence layer.

    - Defines contracts via interfaces
    - Implements database queries (Eloquent, Query Builder, etc.)

    Benefits:

    - ✅ Enables easy testing (mocking repositories)
    - ✅ Allows swapping data sources without affecting business logic 3. Service
3. Service Contains business rules and application use cases. Responsibilities:

    - Orchestrates workflows
    - Applies domain validation

    Throws domain-specific exceptions

    - ✅ HTTP-agnostic
    - ❌ No request / response handling
    - ❌ No direct database queries
4. Controller Acts as the delivery layer. Responsibilities:

    - Receives HTTP requests.
    - Delegates execution to services.
    - Returns standardized API responses.

    Controllers remain thin and predictable.
5. Service Provider Responsible for dependency injection configuration.

    - Binds interfaces to concrete implementations.
    - Registers package services, middleware, and handlers.

    This ensures loose coupling and extensibility.

### Centralized Exception Handling

[](#centralized-exception-handling)

All exceptions—framework, validation, authorization, or domain-specific—are handled in a single place and transformed into a standardized API response. This pattern is also known as:

```
- Exception-to-Response Mapping.
- API Response Envelope Pattern.
- Opinionated API Layer.

```

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel 9, 10, 11, 12

Installation
------------

[](#installation)

Install via Composer:

```
composer require ixspx/module-generator

```

⚙ Manual Provider Registration
------------------------------

[](#-manual-provider-registration)

If package discovery is disabled, register the provider manually in bootstrap/providers.php:

```
'providers' => [
    // Other service providers...
    Ixspx\ModuleGenerator\Providers\ModuleGeneratorServiceProvider::class,
]

```

🛠 Usage
-------

[](#-usage)

#### Generate Standard API Structure

[](#generate-standard-api-structure)

Run the following command to generate the standard API structure:

```
  php artisan make:api-install

```

You may add the --force option to overwrite existing API files.

##### Register API Configuration

[](#register-api-configuration)

After running make:api-install, you must manually register the API configuration in bootstrap/app.php:

```
use Illuminate\Support\Facades\Route;
use App\Exceptions\ApiExceptionRegistrar;
use App\Http\Middleware\ForceJsonResponse;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__ . '/../routes/web.php',
        commands: __DIR__ . '/../routes/console.php',
        health: '/up',
        then: function ($router) {
            Route::prefix('api/v1')
                ->group(base_path('routes/api.php'));
        }
    )
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->append(ForceJsonResponse::class);
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        ApiExceptionRegistrar::register($exceptions);
    })->create();

```

#### Generate a Module

[](#generate-a-module)

Generate a new module using the following command:

```
  php artisan make:mod {{nameModule}}

```

Example:

```
php artisan make:mod OrderPayment

```

After the command finished, you will see a notification simillar to the flowing:

[![alt text](image.png)](image.png)

##### ⚠️ Important:

[](#️-important)

You must register the generated module service provider manually in bootstrap/providers.php. This command generates a complete module structure based on a predefined layered architecture (Controller, Service, Repository, Interface, etc.).

#### OR Generate API Response Helper

[](#or-generate-api-response-helper)

To generate the API response helper, run:

```
php artisan make:api-response

```

📄 License
---------

[](#-license)

This project is open-source software licensed under the MIT License. See the see [LICENSE](LICENSE)

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

3

Last Release

87d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b926d77be7c5351b45e511b18b05bea584b052d5e5a67eebb325683b80087640?d=identicon)[saul-paulus](/maintainers/saul-paulus)

---

Top Contributors

[![saul-paulus](https://avatars.githubusercontent.com/u/55346618?v=4)](https://github.com/saul-paulus "saul-paulus (60 commits)")

---

Tags

apilaravelmodule-generatormodulemodule generatorMod

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ixspx-module-generator/health.svg)

```
[![Health](https://phpackages.com/badges/ixspx-module-generator/health.svg)](https://phpackages.com/packages/ixspx-module-generator)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M682](/packages/barryvdh-laravel-ide-helper)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

765.7M124](/packages/saloonphp-laravel-plugin)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
