sinemacula/laravel-api-toolkit
Laravel API Toolkit helps you build consistent, production-ready JSON APIs with less boilerplate. It includes standardized responses, exception handling, pagination, filtering, sorting, and resource helpers, plus reusable utilities that streamline common API development tasks.
composer require sinemacula/laravel-api-toolkit, then publish the config if you need to change defaults: php artisan vendor:publish --tag=api-toolkit-config.config/api-toolkit.php (defaults for filters, sorting, pagination, includes) and the src/ tree — Filters, Sorting, Resources, and the response/exception handlers are the four areas you'll touch day-to-day.GET /api/users?filter[name]=jane&sort=-created_at. That gives you a working query-string API in a single controller method.filter, sort, include, fields, paginate) before writing custom filters — most integration work is mapping your models onto that contract.index/show call and push field selection, relationship loading, and response shaping into resource classes. This is the package's core opinion and fighting it causes duplication.apply() for things like date ranges, LIKE searches, or enum mapping. Keep each filter single-purpose and composable; the toolkit chains them for you.orWhere, nested where groups), wrap it in a closure ($this->where(function ($q) { ... })) so it stays grouped inside the caller's existing constraints.include parameter with the resource's allowed relationships and verify the generated queries; add withCount/constrained eager loads in the resource rather than in the controller.meta/links.$or condition can no longer escape the caller's scope. Prior versions could produce WHERE tenant_id = ? AND a = ? OR b = ?, leaking rows across tenant/soft-delete/authorization scopes. Upgrade immediately if you expose filters to untrusted input, and audit custom filters that call orWhere directly — wrap them in a grouping closure so the behaviour is explicit rather than relying on the package fix.orWhere is the sharpest tool in the box. Any custom filter using it should be tested with a scope active (tenant, soft deletes, published-only) to confirm the OR is contained.php artisan config:clear in local dev — stale cached config is the usual cause of "my allowed filters are ignored."sort value into orderBy; only pass column names that survived the whitelist, and map public names to real columns.fields/toArray overrides, and the response/exception handlers. Avoid overriding the request parsing itself; that's where upgrades (like this one) land.DB::listen or assertDatabaseCount style assertions catch scope escapes and N+1s that response-shape tests miss.How can I help you explore Laravel packages today?