Download the PHP package dandoetech/laravel-generic-api without Composer
On this page you can find all versions of the php package dandoetech/laravel-generic-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dandoetech/laravel-generic-api
More information about dandoetech/laravel-generic-api
Files in dandoetech/laravel-generic-api
Package laravel-generic-api
Short Description Registry-driven CRUD proxy for Laravel. Validation, policies, filtering, and consistent JSON responses.
License MIT
Homepage https://github.com/dandoetech/laravel-generic-api
Informations about the package laravel-generic-api
Laravel Generic API
Pre-release — Architecture by senior tech lead, implementation largely AI-assisted with human review. Not fully reviewed. Architecture may change before v1.0.0.
Registry-driven CRUD controller for Laravel. One controller handles all resources — validation, authorization, filtering, sorting, pagination, and computed fields are derived from the Resource Registry.
Installation
The service provider is auto-discovered. Publish the config:
Requires dandoetech/laravel-resource-registry.
Quick Start
Define a resource with HasEloquentModel (and optionally HasPolicy):
Routes are registered automatically. The API is ready:
Routes
All routes are prefixed with config('ddt_api.prefix') (default: api/v1) and use the api middleware plus AuthorizeResource.
| Method | Route | Action |
|---|---|---|
| GET | {resource} |
List with pagination, filtering, sorting |
| POST | {resource} |
Create |
| GET | {resource}/{id} |
Show |
| PATCH | {resource}/{id} |
Update (partial) |
| DELETE | {resource}/{id} |
Delete |
| POST | {resource}/actions/{action} |
Execute mass action |
Responses
List:
Single item:
Query Syntax
Only fields listed in filterable() and sortable() on the resource are accepted. Unknown fields return a 422 Unprocessable Entity. This includes computed fields — filtering and sorting on category_name or orders_count works out of the box.
Filtering
Operators: eq, neq, gt, gte, lt, lte, like, between
Sorting
Search
Search applies LIKE %term% for string fields and exact match for non-string fields.
Pagination
Query Profiles
Override filterable/sortable/searchable per context. Profiles can be defined on the Resource class:
Activate with ?profile=admin or ?profile=active.
Authorization
The AuthorizeResource middleware handles authorization automatically for resources that implement HasPolicy:
| Request | Gate ability | Subject |
|---|---|---|
| GET (list) | viewAny |
Model class |
| GET (single) | view |
Model instance |
| POST | create |
Model class |
| PATCH | update |
Model instance |
| DELETE | delete |
Model instance |
| Mass action | action |
Model class + action name |
Resources without HasPolicy skip authorization entirely.
Validation
Validation rules are derived from the resource definition:
- POST (create): Field rules applied directly. Non-nullable fields without explicit rules get
required. - PATCH (update): All rules wrapped with
sometimes(PATCH semantics — only validate provided fields).
Configuration
config/ddt_api.php:
Testing
License
MIT
All versions of laravel-generic-api with dependencies
illuminate/support Version ^11.0 || ^12.0
illuminate/routing Version ^11.0 || ^12.0
illuminate/validation Version ^11.0 || ^12.0
illuminate/auth Version ^11.0 || ^12.0
illuminate/contracts Version ^11.0 || ^12.0
illuminate/http Version ^11.0 || ^12.0
illuminate/database Version ^11.0 || ^12.0
dandoetech/resource-registry Version ^0.1 || ^0.2
dandoetech/laravel-resource-registry Version ^0.1 || ^0.2