Download the PHP package ashique-ar/laravel-crud-generator without Composer
On this page you can find all versions of the php package ashique-ar/laravel-crud-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ashique-ar/laravel-crud-generator
More information about ashique-ar/laravel-crud-generator
Files in ashique-ar/laravel-crud-generator
Package laravel-crud-generator
Short Description A powerful, configuration-driven CRUD API generator for Laravel with advanced features including permissions, filtering, sorting, bulk operations, and custom logic handlers.
License MIT
Homepage https://github.com/ashique-ar/laravel-crud-generator
Informations about the package laravel-crud-generator
Laravel CRUD Generator
A powerful, configuration-driven CRUD API generator for Laravel applications. Generate complete REST APIs with advanced features like permissions, filtering, sorting, validation, relations management, and custom business logic handlers - all through simple configuration.
β¨ Features
- π Zero-Code CRUD APIs - Generate complete REST APIs through configuration
- οΏ½ Advanced Relations Management - Dynamic form relations with dependent dropdowns
- οΏ½π Permission Integration - Built-in support for Spatie Laravel Permission
- π― Custom Logic Handlers - Extend with custom business logic easily
- π Advanced Filtering - Search across multiple fields with configurable operators
- π Smart Sorting - Multi-field sorting with default configurations
- β‘ Bulk Operations - Perform operations on multiple resources at once
- ποΈ Soft Deletes Support - Full soft delete support with restore capabilities
- β Automatic Validation - Validation rules defined in configuration
- π API Documentation - Auto-generated OpenAPI/Swagger documentation
- π οΈ Artisan Commands - Powerful commands for scaffolding and management
- π§ͺ Fully Tested - Comprehensive test suite included
π Requirements
- PHP 8.1+
- Laravel 10.x | 11.x | 12.x
- Spatie Laravel Permission (automatically installed)
π¦ Installation
Install the package via Composer:
Run the installation command:
This will:
- Publish the configuration file
- Set up middleware
- Register routes
- Generate initial permissions (optional)
π Quick Start
1. Generate Your First Resource
Use the artisan command to quickly scaffold a new resource:
2. Configure Relations (New!)
Add relations to enable dynamic form management:
3. Example Resource Configuration
Here's a complete example of a resource with relations in config/crud.php
:
4. Register API Routes
Add to your routes/api.php
or service provider:
Your API endpoints will be available at:
GET /api/v1/vehicles
- List vehicles with pagination, filtering, sortingPOST /api/v1/vehicles
- Create a new vehicleGET /api/v1/vehicles/{id}
- Get a specific vehiclePUT /api/v1/vehicles/{id}
- Update a vehicleDELETE /api/v1/vehicles/{id}
- Delete a vehicleGET /api/v1/vehicles/docs
- API documentation for vehicles resource
π οΈ Artisan Commands
Resource Management
Options:
--model=
: Specify the model class--logic
: Generate a custom logic class--resource
: Generate an API resource class--permissions
: Generate permissions for this resource--force
: Overwrite existing files
Relations Management
Options:
--field=
: Field name (e.g., category_id)--entity=
: Target entity name (e.g., categories)--label-field=
: Label field (default: name)--value-field=
: Value field (default: id)--display-field=
: Display field for tables (default: same as label-field)--searchable
: Make the relationship searchable--nullable
: Make the relationship optional (not required)--depends-on=
: Field this relationship depends on--filter-by=
: Field to filter by when depends-on is set--interactive
: Interactive mode
Custom Logic
Permissions
Installation & Setup
π Relationships Configuration
The relationships system allows you to create dynamic forms with dependent dropdowns and complex relationships. This unified approach handles both Laravel Eloquent relationships and form field relationships in one configuration.
Relationship Types
- Single Select - For foreign key relationships (belongs to)
- Multiple Select - For many-to-many relationships (coming soon)
- Dependent Dropdowns - Where one field depends on another
Relationship Configuration Structure
Real-World Examples
Vehicle Management System
Blog Post with Tags
Frontend Integration
Your dynamic frontend can read these configurations and automatically:
- Generate appropriate form controls based on relationship configuration
- Fetch options from the appropriate endpoints (
/api/crud/{entity}
) - Handle dependent dropdowns by watching parent field changes
- Support search functionality in dropdowns
- Validate required/optional fields
- Display appropriate fields in tables and lists
Example frontend usage:
π API Endpoints
All resources automatically get the following endpoints:
Standard CRUD Operations
Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/{resource} |
List all items with pagination, filtering, sorting |
POST |
/api/v1/{resource} |
Create a new item |
GET |
/api/v1/{resource}/{id} |
Get a specific item |
PUT |
/api/v1/{resource}/{id} |
Update an item |
DELETE |
/api/v1/{resource}/{id} |
Delete an item |
Additional Endpoints
Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/{resource}/config |
Get resource configuration (including relations) |
GET |
/api/v1/{resource}/docs |
API documentation for this resource |
POST |
/api/v1/{resource}/bulk |
Bulk operations (delete, update) |
POST |
/api/v1/{resource}/{id}/restore |
Restore soft-deleted item |
Query Parameters
Pagination
Search
Sorting
Filtering
Including Relations
βοΈ Configuration Options
Global Configuration
Edit config/crud.php
to customize global settings:
Resource Configuration Options
Each resource supports these configuration options:
π Available Endpoints
For each configured resource, the following endpoints are automatically generated:
Method | Endpoint | Description |
---|---|---|
GET |
/api/v1/{resource} |
List resources with pagination, search, and sorting |
POST |
/api/v1/{resource} |
Create a new resource |
GET |
/api/v1/{resource}/{id} |
Get a specific resource |
PUT/PATCH |
/api/v1/{resource}/{id} |
Update a resource |
DELETE |
/api/v1/{resource}/{id} |
Delete a resource |
POST |
/api/v1/{resource}/bulk |
Bulk operations (if enabled) |
GET |
/api/v1/{resource}/trashed |
List soft-deleted resources (if enabled) |
POST |
/api/v1/{resource}/{id}/restore |
Restore soft-deleted resource (if enabled) |
DELETE |
/api/v1/{resource}/{id}/force |
Force delete resource (if enabled) |
GET |
/api/v1/{resource}/docs |
API documentation for the resource |
Query Parameters
Pagination
page
- Page number (default: 1)per_page
- Items per page (default: 15, max: 100)
Search
search
- Search term across configured searchable fieldssearch_operator
- Search operator:like
,exact
,starts_with
,ends_with
(default:like
)
Sorting
sort
- Field to sort bydirection
- Sort direction:asc
ordesc
(default:asc
)
Filtering
filter[field]
- Filter by specific field valuefilter[field][operator]
- Filter with specific operator (=
,!=
,>
,<
,>=
,<=
,like
,in
,between
)
π§ Advanced Usage
Model Namespacing
The package supports flexible model namespacing to accommodate different project structures:
When using artisan commands, you can specify models in several ways:
Custom Logic Handlers
Create custom business logic for your resources:
This generates:
Then update your configuration:
Adding New Resources
Use the artisan command to quickly add new resources:
This will interactively help you configure:
- Model class and table
- Fillable fields
- Validation rules
- Search and sort configuration
- Permissions
- Relations
- Custom logic handler (optional)
Bulk Operations
Perform operations on multiple resources:
Permissions
The package integrates seamlessly with Spatie Laravel Permission:
API Documentation
Access auto-generated documentation:
Returns OpenAPI 3.0 compatible JSON that can be used with Swagger UI or similar tools.
π Configuration
The package uses a comprehensive configuration system in config/crud.php
. Here's a complete reference:
Global Configuration
π§ͺ Testing
The package includes comprehensive tests. Run them using:
Example Test
π Security
Permission Middleware
The package includes built-in permission checking:
This checks for permissions like:
view-users
for GET requestscreate-users
for POST requestsedit-users
for PUT/PATCH requestsdelete-users
for DELETE requests
Validation
All requests are automatically validated using the rules defined in your configuration:
Use {{id}}
in update rules to exclude the current record from unique checks.
Mass Assignment Protection
Only fields defined in fillable
arrays are allowed for mass assignment, providing protection against mass assignment vulnerabilities.
π Examples
Complete Vehicle Management System
See examples/vehicle-crud-config.php
for a complete example of a vehicle management system with:
- Vehicle classes, makes, models
- Dependent dropdowns (model depends on make)
- Complex relationships
- Full CRUD operations
Blog System
π€ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
π License
The MIT License (MIT). Please see License File for more information.
π Support
- Documentation: This README and inline documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
πΊοΈ Roadmap
- [ ] GraphQL support
- [ ] Real-time updates with WebSockets
- [ ] Advanced caching strategies
- [ ] Export functionality (CSV, Excel, PDF)
- [ ] Import functionality with validation
- [ ] Audit logging
- [ ] API rate limiting per resource
- [ ] Resource versioning
- [ ] Custom field types and validation rules
Made with β€οΈ by Ashique AR ], ],
// Resource definitions
'resources' => [
// Your resources here...
]
]; bash composer test bash composer test-coverage
## π Configuration
See the [Configuration Guide](docs/configuration.md) for detailed configuration options.
## π Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## π€ Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## π Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## π License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## π Credits
- [Your Name](https://github.com/ashique-ar)
- [All Contributors](../../contributors)
## π‘ Support
- [Documentation](https://github.com/ashique-ar/laravel-crud-generator#documentation)
- [Issues](https://github.com/ashique-ar/laravel-crud-generator/issues)
- [Discussions](https://github.com/ashique-ar/laravel-crud-generator/discussions)
---
Made with β€οΈ for the Laravel community
All versions of laravel-crud-generator with dependencies
laravel/framework Version ^10.0|^11.0|^12.0
spatie/laravel-permission Version ^5.0|^6.0