lauchoit / laravel-hex-mod
Modular scaffolding generator for Laravel (Hexagonal Architecture)
Requires
- php: ^8.1
This package is not auto-updated.
Last update: 2025-07-12 17:27:36 UTC
README
Laravel Hex Mod
โ๏ธ A modular scaffolding generator for Laravel based on Hexagonal Architecture (Ports & Adapters).
๐ฆ 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.