Download the PHP package dev-toolbelt/laravel-fast-crud without Composer
On this page you can find all versions of the php package dev-toolbelt/laravel-fast-crud. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dev-toolbelt/laravel-fast-crud
More information about dev-toolbelt/laravel-fast-crud
Files in dev-toolbelt/laravel-fast-crud
Package laravel-fast-crud
Short Description Laravel package for rapid CRUD API scaffolding with filtering, sorting, pagination and CSV export
License MIT
Homepage https://github.com/dev-toolbelt/laravel-fast-crud
Informations about the package laravel-fast-crud
Laravel Fast CRUD
A powerful Laravel package for rapid CRUD API scaffolding. Build complete RESTful APIs in minutes with minimal boilerplate, following best practices and the JSend specification.
Features
- Works exclusively with Laravel 11+
- 9 pre-built actions (Create, Read, Update, Delete, Soft Delete, Restore, Search, Options, Export CSV)
- 14+ search operators for flexible filtering (eq, like, between, in, json, etc.)
- Multi-field term search via
filter[term]with database-awareLIKE/ILIKE - Built-in validation using Laravel's validation rules
- Automatic route registration with permission middleware support
- Hook system for customization without overriding entire methods
- Global and per-action configuration
- Soft delete with audit trail (who deleted and when)
- CSV export with custom column mapping and dot notation support
- Consistent API responses following JSend specification
Requirements
- PHP ^8.2
- Laravel ^11.0
Installation
Publish the configuration (optional):
Quick Start
1. Create a Controller
2. Register Routes
That's it! You now have a complete CRUD API.
Available Actions
| Action | Method | Route | Permission | Description |
|---|---|---|---|---|
| Search | GET |
/products |
{module}.access.search |
List with filtering, sorting, pagination |
| Create | POST |
/products |
{module}.access.create |
Create a new record |
| Read | GET |
/products/{id} |
{module}.access.view |
Get a single record |
| Update | PUT/PATCH |
/products/{id} |
{module}.access.update |
Update a record |
| Delete | DELETE |
/products/{id} |
{module}.access.delete |
Permanently delete a record |
| Soft Delete | DELETE |
/products/{id}/soft |
{module}.access.delete |
Soft delete with audit |
| Restore | PATCH/PUT |
/products/{id}/restore |
{module}.access.restore |
Restore a soft deleted record |
| Options | GET |
/products/options |
none | Label-value pairs for HTML selects |
| Export CSV | GET |
/products/export-csv |
{module}.access.exportCsv |
Export filtered data to CSV |
Note: The
Optionsroute (GET /options) has no permission middleware and is always publicly accessible (subject to any other middleware applied to the surrounding route group). This makes it easy to populate HTML<select>fields and dropdowns without requiring the user to have explicit permissions.
Search Operators
Filter your data with powerful operators via query string:
| Operator | Description | Example |
|---|---|---|
eq |
Equals | filter[status][eq]=active |
neq |
Not equals | filter[status][neq]=deleted |
like |
Contains (ILIKE %value%) | filter[name][like]=phone |
in |
In list | filter[status][in]=a,b,c |
nin |
Not in list | filter[status][nin]=x,y |
gt |
Greater than | filter[price][gt]=100 |
gte |
Greater than or equal | filter[price][gte]=100 |
lt |
Less than | filter[price][lt]=500 |
lte |
Less than or equal | filter[price][lte]=500 |
btw |
Between (dates or numbers) | filter[created_at][btw]=2024-01-01,2024-12-31 |
gtn |
Greater than or NULL | filter[stock][gtn]=10 |
ltn |
Less than or NULL | filter[stock][ltn]=5 |
nn |
Not null | filter[deleted_at][nn]=1 |
json |
JSON contains | filter[tags][json]=electronics |
Term Search
In addition to operator-based filters, Search supports a configurable term filter
that matches multiple fields using LIKE (MySQL/SQLite) or ILIKE (PostgreSQL).
Usage
Controller Configuration
Query Generated (Example)
For PostgreSQL, filter[term]=john with the fields above generates a query equivalent to:
Custom Term Key
Sorting
Sort by one or multiple fields (prefix with - for descending):
Pagination
Available Hooks
Customize behavior by overriding hooks in your controller:
| Action | Available Hooks |
|---|---|
| Create | createValidateRules(), beforeCreateFill(), beforeCreate(), afterCreate() |
| Read | modifyReadQuery(), afterRead() |
| Update | updateValidateRules(), modifyUpdateQuery(), beforeUpdateFill(), beforeUpdate(), afterUpdate() |
| Delete | modifyDeleteQuery(), beforeDelete(), afterDelete() |
| Soft Delete | modifySoftDeleteQuery(), beforeSoftDelete(), afterSoftDelete(), getSoftDeleteUserId() |
| Restore | modifyRestoreQuery(), beforeRestore(), afterRestore() |
| Search | modifySearchQuery(), modifyFilters(), afterSearch() |
| Options | modifyOptionsQuery(), afterOptions() |
| Export CSV | modifyExportCsvQuery() |
Hook Examples
Validation
The package provides built-in validation using Laravel's validation system. Define rules by overriding createValidateRules() or updateValidateRules() methods.
Validation Error Response
When validation fails, a 400 response is returned with detailed error information:
Each error includes:
field: The field that failed validationerror: The rule name (e.g.,required,email,max,unique)value: The submitted valuemessage: Laravel's validation message
For detailed validation documentation, see:
- Create Action - Validation
- Update Action - Validation
Configuration
Configurable HTTP Status Codes
Each action supports a configurable http_status option to customize the HTTP status code returned on successful responses:
Validation Error HTTP Status
All validation errors (empty payload, invalid UUID, required field, column not found) use the global.validation.http_status configuration:
To return a different status code for validation errors:
Available status codes are defined in the DevToolbelt\Enums\Http\HttpStatusCode enum.
Selective Route Registration
Include or exclude specific actions:
CSV Export
Configure CSV export with custom columns and nested relationships:
API Response Format
All responses follow the JSend specification:
Success Response:
Success with Pagination:
Fail Response (client error):
Empty Payload Error:
Invalid UUID Error:
Documentation
Detailed documentation for each component:
Core:
- Router - Route registration and permission middleware
Actions:
- Create Action
- Read Action
- Update Action
- Delete Action
- Soft Delete Action
- Restore Action
- Search Action
- Options Action
- Export CSV Action
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
Code Quality Requirements
| Check | Tool | Requirement |
|---|---|---|
| Tests | PHPUnit | All tests must pass |
| Coverage | PCOV | Minimum 85% coverage |
| Code Style | PHP CodeSniffer | PSR-12 compliant |
| Static Analysis | PHPStan | Level 6, no errors |
Pull Request Guidelines
Before submitting a PR, ensure:
- All tests pass:
composer test - Coverage is at least 85%:
composer test:coverage - Code style is correct:
composer phpcs - No static analysis errors:
composer phpstan
Important: Pull requests with coverage below 85% will be automatically blocked by CI.
Coverage Report
- Dashboard: Codecov
- HTML Report: GitHub Pages
License
MIT License. See LICENSE for details.
All versions of laravel-fast-crud with dependencies
dev-toolbelt/jsend-payload Version ^1.0
dev-toolbelt/enums Version ^1.0
laravel/framework Version ^11.0