abacus / module-builder
A Laravel inhouse package for building modules
v3.0.2
2025-01-26 10:08 UTC
Requires
- php: 8.*
- laravel/framework: >=8.0
README
Module builder created to escape the boilerplating when creating new modules, based on 3-layer app
- Business ( Provider, Data, Creator, Facade )
- Communication ( Controller, Request )
- Persistence ( Model, Migration, Saver, Updater, Deleter )
The core principle
This package is organized the same way the modules are generated, across that,
it uses chain responsability for the factory services to generate the classes.
How to use
To generate a new whole module, for example CarModule, you would type into the terminal.
If you want it to be translated, you add the --translated option to the command.
php artisan abacus:create:module Car
Don't forget to update your bootstrap/providers.php
<?php use App\Providers\AppServiceProvider; use App\Business\Car\CarServiceProvider; return [ AppServiceProvider::class, CarServiceProvider::class, ];
PS: In case your default controller is moved from default location,update the Communication/{module}/Controllers/*Controller.php accordingly.
<?php declare(strict_types=1); namespace App\Communication\Car\Controllers; use App\Business\Car\Data\CarData; use App\Business\Car\Facades\CarFacade; use App\Communication\Car\Requests\CarRequest; use App\Http\Controllers\Controller; // <- Check this class CarController extends Controller { public function __construct(private readonly CarFacade $facade) { } public function store(CarRequest $request): int { return $this->facade->store(CarData::fromRequest($request)); } public function update(int $id, CarRequest $request): int { return $this->facade->update($id, CarData::fromRequest($request)); } public function delete(int $id): ?bool { return $this->facade->delete($id); } }