vitisstudio / restdb-jsonapi
JSON:API adapter for the RestDB Eloquent driver
v0.1.2
2026-08-06 17:29 UTC
Requires
- php: ^8.2
- illuminate/console: ^12.0||^13.0
- illuminate/contracts: ^12.0||^13.0
- illuminate/database: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- vitisstudio/restdb: ^0.1
README
A complete, preconfigured JSON:API v1.1 adapter for the RestDB Eloquent driver — query compiler, compound-document parser with an identity map, three pagination strategies, pluggable filter dialects, and spec-driven model generation.
'crm' => [ 'driver' => 'restdb', 'adapter' => 'json-api', 'base_url' => env('CRM_API_URL'), 'pagination' => ['strategy' => 'page-number', 'size' => 50, 'meta_total' => 'meta.page.total'], 'filter_dialect' => 'nested-operator', // or 'comma-list', or your FilterDialect class 'name_mapping' => 'camel', // or 'kebab', 'none' ],
class Article extends Model { use \Vitis\RestDB\JsonApi\IsJsonApiResource; protected $connection = 'crm'; protected $table = 'articles'; }
Highlights:
find(42)→GET /articles/42; filters/sorts/sparse fieldsets compile tofilter[…],sort,fields[type]with name mapping.with('comments.author')costs zero extra HTTP — unconstrained eager loads rideinclude=and hydrate recursively from the compound document's identity map. Constrained closures fall back to real queries.- Pagination follows
links.nextverbatim; totals come from your configuredmeta_totalpath and power one-requestpaginate()andcount(). - Writes are typed resource documents:
POST {data:{type,attributes}}, dirty-onlyPATCH,DELETE; error-document pointers map to field-keyed validation messages. - Honest capability baseline: only what the spec guarantees; filter operators
come from the dialect's
supports().
Spec-driven tooling:
php artisan restdb:make-models crm --spec=storage/api-specs/crm.json \
--path=app/Models/Crm --namespace="App\Models\Crm"
php artisan restdb:discover crm --spec=storage/api-specs/crm.json # + --check in CI
Generated models are committed code you own — casts from schema types,
relations from spec relationships, never overwritten without --force.