Download the PHP package yassin-ahmed/laravel-api-crud-generator without Composer
On this page you can find all versions of the php package yassin-ahmed/laravel-api-crud-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-api-crud-generator
Laravel API CRUD Generator
A powerful Laravel package that generates complete CRUD APIs with a single command. This package creates everything you need for a fully functional REST API including models, controllers, requests, resources, migrations, factories, seeders, tests, and routes.
๐ Features
- Complete CRUD Generation: Models, Controllers, Requests, Resources, Migrations, Factories, Seeders, Tests, and Routes
- Field Type Support: String, text, integer, boolean, date, email, JSON, decimal, float, and more
- Relationship Support: BelongsTo and HasMany relationships
- Validation: Automatic validation rules generation based on field types
- API Resources: JSON API responses with proper formatting
- Pagination: Built-in pagination support with meta information
- Search & Filtering: Search functionality and sorting options
- Factory & Seeders: Automatic fake data generation for testing
- Feature Tests: Complete test suite for all CRUD operations
- Smart Fake Data: Context-aware fake data generation (emails, names, phones, etc.)
๐ฆ Installation
Install the package via Composer:
Publish the package configuration (optional):
๐ฏ Quick Start
Generate a complete CRUD API with a single command:
This creates:
- Migration file
- Post model
- PostController (API)
- Store/Update request classes
- PostResource
- API routes
- PostFactory
- PostSeeder
- Feature tests
๐ Usage
Basic Usage
Command Options
| Option | Description | Example |
|---|---|---|
--fields |
Define model fields with types | --fields="name:string,age:integer" |
--relations |
Define model relationships | --relations="belongsTo:User,hasMany:Post" |
--force |
Overwrite existing files | --force |
Field Types
| Type | Description | Validation Rule |
|---|---|---|
string |
Short text (255 chars) | string\|max:255 |
text |
Long text | string |
integer |
Whole numbers | integer |
boolean |
True/false values | boolean |
date |
Date values | date |
email |
Email addresses | email |
json |
JSON data | json |
decimal |
Decimal numbers | numeric |
float |
Floating point numbers | numeric |
Relationship Types
| Type | Description | Example |
|---|---|---|
belongsTo |
Many-to-one relationship | belongsTo:User |
hasMany |
One-to-many relationship | hasMany:Comment |
๐ Examples
E-commerce Product
Blog System
User Management
๐ง Generated Files Structure
After running the command, the following files are created:
๐ API Endpoints
The generated controller provides these endpoints:
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/your-models |
List all records (with pagination) |
POST |
/api/your-models |
Create new record |
GET |
/api/your-models/{id} |
Show specific record |
PUT/PATCH |
/api/your-models/{id} |
Update record |
DELETE |
/api/your-models/{id} |
Delete record |
Query Parameters
search- Search in name fieldsort_by- Field to sort bysort_direction- Sort direction (asc/desc)per_page- Records per page (default: 15)
Example API Calls
๐งช Testing
The package generates comprehensive feature tests. Run them with:
๐ After Generation
-
Run migrations:
-
Register routes (if not using automatic discovery):
-
Run seeders (optional):
- Customize as needed:
- Update validation rules in request classes
- Modify API resource fields
- Add custom methods to controllers
- Enhance factory definitions
โก Advanced Features
Custom Validation
Update the generated request classes to add custom validation:
Custom API Resources
Enhance the generated resource classes:
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This package is open-sourced software licensed under the MIT license.
๐ Support
If you encounter any issues or have questions:
- Check the issues page
- Create a new issue if your problem isn't already reported
- Provide detailed information about your Laravel version and the command you used
๐ Credits
Created by Yassin
Made with โค๏ธ for the Laravel community