lauchoit/laravel-hex-mod

Modular scaffolding generator for Laravel (Hexagonal Architecture)

v1.0.1 2025-06-28 17:22 UTC

This package is not auto-updated.

Last update: 2025-07-12 17:27:36 UTC


README

LauchoIT Logo

Laravel Hex Mod

โš™๏ธ A modular scaffolding generator for Laravel based on Hexagonal Architecture (Ports & Adapters).

License Packagist Made by LauchoIT

๐Ÿ“ฆ Installation

You can install the package via Composer:

composer require lauchoit/laravel-hex-mod --dev

๐Ÿš€ What It Does

This package generates a modular Laravel structure based on Hexagonal Architecture, automating the creation of:

  • โœ… Domain Entities & EntitySource (Model of Laravel)
  • โœ… Application UseCases
  • โœ… Interface Adapters (Controllers, Repositories, Requests, Resources)
  • โœ… Eloquent Models, Migrations, and Factories
  • โœ… Automatic Unit & Feature Tests
  • โœ… Route injection & AppServiceProvider bindings
  • โœ… Shared folder

๐Ÿš€ What It Does

This package scaffolds a complete Laravel module following Hexagonal Architecture, including:

src
โ”œโ”€โ”€ Client
โ”‚ย ย  โ”œโ”€โ”€ Application
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ UseCases
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ CreateClientUseCase.php
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ DeleteByIdClientUseCase.php
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ FindAllClientUseCase.php
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ FindByIdClientUseCase.php
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ UpdateByIdClientUseCase.php
โ”‚ย ย  โ”œโ”€โ”€ Domain
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Entity
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Client.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ClientSource.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Exceptions
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ClientNotFoundException.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Mappers
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ClientMapper.php
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Repository
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ ClientRepository.php
โ”‚ย ย  โ”œโ”€โ”€ Infrastructure
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Controllers
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ClientController.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Model
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Client.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Repository
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ClientRepositoryImpl.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ UseCases
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ CreateClientUseCaseImpl.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ DeleteByIdClientUseCaseImpl.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ FindAllClientUseCaseImpl.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ FindByIdClientUseCaseImpl.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ UpdateByIdClientUseCaseImpl.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Requests
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ CreateClientRequest.php
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ UpdateClientRequest.php
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ Resources
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ ClientResource.php
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ Routes
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ ClientRoutes.php
โ”‚ย ย  โ””โ”€โ”€ Tests
โ”‚ย ย      โ”œโ”€โ”€ Feature
โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ CreateClientTest.php
โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ DeleteByIdClientTest.php
โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ FindAllClientTest.php
โ”‚ย ย      โ”‚ย ย  โ”œโ”€โ”€ FindByIdClientTest.php
โ”‚ย ย      โ”‚ย ย  โ””โ”€โ”€ UpdateByIdClientTest.php
โ”‚ย ย      โ””โ”€โ”€ Unit
โ”‚ย ย          โ””โ”€โ”€ Domain
โ”‚ย ย              โ”œโ”€โ”€ Entity
โ”‚ย ย              โ”‚ย ย  โ”œโ”€โ”€ ClientSourceTest.php
โ”‚ย ย              โ”‚ย ย  โ””โ”€โ”€ ClientTest.php
โ”‚ย ย              โ””โ”€โ”€ Exceptions
โ”‚ย ย                  โ””โ”€โ”€ ClientNotFoundExceptionTest.php
โ””โ”€โ”€ Shared
    โ””โ”€โ”€ Responses
        โ”œโ”€โ”€ ApiResponse.php
        โ””โ”€โ”€ ValidationResponse.php

๐Ÿงฑ Usage

You can run the command in different ways depending on your needs:

Basic Usage

php artisan make:hex-mod client

This command will generate a complete module for Client with default fields attribute1 and attribute2 all string.

With fields Usage

php artisan make:hex-mod client -f name,lastname,direction,description

This command will generate a complete module for Client with specific field, if your not provider type, the system makes field with a string type.

With fields and type Usage

php artisan make:hex-mod client -f name,lastname,direction,year:integer,registred_at:date,data:json,metadata:json

The type available are: string, integer, float, boolean, date, datetime, json, longText.

This command will generate a complete module for Client with specific field and type, if your not provider types, the system makes field with a string type.

Without Tests

php artisan make:hex-mod client --skip-test

If you provide the --skip-test option, the generator will skip creating tests for the module.

Route

The generator automatically creates a route file for the module, which you can find in src/Client/Infrastructure/Routes/ClientRoutes.php.

  • You can customize the routes as needed, and they will be automatically loaded by the application.
  • This route file is register automatically in the bootstrap/app.php of your Laravel application.
  • You can see the routes in the php artisan route:list command.

๐Ÿงช Test Coverage

Note: you need to have the phpunit package installed and configured in your Laravel project to run the tests. You need run migratrions before runnig the tests. The generator produces unit and feature tests for:

  • Entity classes
  • NotFound exceptions
  • UsesCases feature scenarios

Run your tests:

php artisan test

๐Ÿ™Œ Made with โค๏ธ by LauchoIT

Feel free to contribute or suggest features via GitHub issues or PRs.

๐Ÿ“œ License

This package is open-sourced software licensed under the MIT license.