Download the PHP package gabylis/api-foundation without Composer
On this page you can find all versions of the php package gabylis/api-foundation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api-foundation
gabylis/api-foundation
Opinionated Laravel API base package: structured JSON responses, PHP 8 OpenAPI attribute scaffolding, and an Artisan generator for documented controllers.
Built from real production patterns on Laravel + l5-swagger projects.
Requirements
- PHP 8.1+
- Laravel 10, 11, or 12
darkaonline/l5-swagger^8.5
Installation
1. Install the package
2. Install and publish l5-swagger
3. Publish the OpenAPI info file
This creates app/OpenApi/OpenApiInfo.php — edit it to set your API title, version, server URL, and security scheme:
4. Configure l5-swagger scanning
In config/l5-swagger.php, set the annotations path inside documentations.default.paths:
Note: You only need to scan
app/— the publishedOpenApiInfo.phplives there. Do not addvendor/gabylis/api-foundation/srcto the annotations paths, as the package no longer contains any OpenAPI annotations in the vendor folder.
5. Generate docs
Open http://localhost:8000/api/documentation.
What's included
OpenApiInfo.php (published to app/OpenApi/)
Global OpenAPI metadata — edit freely after publishing. Re-generate docs after any change:
ApiBaseController
Base controller with the ApiResponse trait. All your API controllers extend this:
ApiFormRequest
Base form request that always returns JSON on validation failure — no more 302 redirects from APIs:
Validation error response (always JSON, status 422):
make:api-controller command
Generates a fully documented controller with PHP 8 #[OA\...] attributes for all CRUD methods:
Options:
| Option | Description |
|---|---|
--resource |
Route resource name (e.g. products). Defaults to snake_case of class name. |
--tag |
OpenAPI tag label shown in Swagger UI. |
--namespace |
Override default namespace (App\Http\Controllers\Api). |
--path |
Override output path (app/Http/Controllers/Api). |
--force |
Overwrite existing file. |
Then add the route and regenerate:
Response envelope
Success:
Paginated:
Error:
Available methods
| Method | Description |
|---|---|
sendResponse($data, $message, $status = 200) |
Standard success response |
sendPaginatedResponse($paginator, $message, $resourceClass = null) |
Paginated response with meta |
sendError($message, $data = [], $status = 404) |
Error response |
sendSuccess($message, $status = 200) |
Success with message only, no data |
Full setup checklist
Publishing the stub
To customise the controller generator template:
This creates stubs/api-foundation/api-controller.stub — edit it and the generator will use your version instead of the default.
Running tests
License
MIT
All versions of api-foundation with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/routing Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
darkaonline/l5-swagger Version ^8.5
zircote/swagger-php Version ^4.0