Laravel API skeleton
This is a feature-based API application skeleton.
Requirements
- PHP 8.2+
About
Packages
The skeleton contains the following packages:
diffhead/php-dto- DTO implementationlaravel/framework- Laravel version 12laravel/tinker- Application interpreterlaravel/sanctum- Authentication libraryspatie/laravel-permission- Authorization features
It also includes packages for application testing. See composer.json for details.
Architecture
This is a feature-based skeleton. Every feature has a
service provider which should be included by adding it to
bootstrap/providers.php.
The skeleton has the App\Kernel namespace which contains
some basic utilities, enums, middlewares and other
fundamental components.
Also this application has the App\Shared namespace for
services, events, or other things that will be shared
between features and components.
App\Models namespace should contain global app models
which represent database structures.
Feature
A feature can contain route definitions, event listeners, commands, services, and other required components needed to implement a specific functionality.
I strongly recommend keeping each feature isolated from the others. A good sign of proper isolation is that the application continues to work stably even when a feature is disabled.
Infrastructure
The skeleton contains a Jenkinsfile in the root of the project as
an example of how to build and deploy the application. It also
contains Docker files inside the deploy directory.
Usage
The skeleton includes an app\Feature\Example feature as an example of how to
define features, some shared services and events, and base
migrations with the user model.