laravel-base maintained by jponchiroli
jponchiroli/laravel-base
What it is
A foundation for Laravel 13 APIs. It ships layered base classes (service, repository, DTOs, requests, resources), standardized JSON responses and errors with translated messages (en, pt_BR), and a make:domain command that generates the whole API layer of an entity.
How it works
- You install the package and run one setup command.
php artisan make:domain Productgenerates the controller, service, repository, DTOs, requests and routes of the entity. Each generated class is an empty subclass of a base class that lives in the package.- You only add the migration, the model's
$fillableand the validation rules of the Requests. - The endpoints answer with a fixed envelope (
{ "message": "...", "data": ... }), errors follow one format, and validation messages are derived from the rules and translated.
Generated code belongs to your project, so you can override any behaviour in the entity's own classes.
Installation
Requires PHP 8.3+ and Laravel 13.
composer require jponchiroli/laravel-base
php artisan laravel-base:install
The service provider is discovered automatically. Composer does not run Artisan commands for dependencies, so laravel-base:install is a manual step; it is safe to run more than once. Options, configuration keys and publish tags are in docs/install-and-configuration.md.
Documentation
Technical documentation lives in docs/:
| Topic | |
|---|---|
| Getting started | From install to a working CRUD |
| Architecture | How the package is organized |
| Request lifecycle | What happens to one request |
| Layers | Responsibility of each layer and base class |
| DTOs | How validated data travels |
| Responses and errors | Payload shapes and the error handler |
| Validation and translations | Derived messages and languages |
make:domain |
The generator, stubs and routes |
| Testing | How the package is tested |
Using with AI agents
The package ships a guide for AI coding agents. It tells the agent to run make:domain instead of writing each file by hand, which saves tokens and keeps the code consistent. Publish it into your project as AGENTS.md:
php artisan vendor:publish --tag=laravel-base-agents
Details in docs/ai-agent-guide.md.
Releasing
Planned for the next version: automatic Swagger/OpenAPI documentation, generated by an Artisan command from the existing routes, Requests and Resources.
License
MIT. See LICENSE.