worksofallen / laravel-api-scaffold
A simple way to send batch emails
Installs: 827
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/worksofallen/laravel-api-scaffold
Requires
- php: ^8.1
- ext-json: *
- illuminate/contracts: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- spatie/laravel-package-tools: ^1.12
Requires (Dev)
- guzzlehttp/guzzle: ^7.0.1
- laravel/pint: ^1.2
- mockery/mockery: ^1.5
- orchestra/testbench: ^6.0 || ^7.6 || ^8.0 || ^9.0
- pestphp/pest: ^2.0
- pestphp/pest-plugin-faker: ^1.0 || ^2.0
- pestphp/pest-plugin-laravel: ^1.2 || ^2.0
- pestphp/pest-plugin-mock: ^1.0 || ^2.0
- spatie/laravel-ray: ^1.29
README
A Laravel Artisan command to quickly scaffold a complete RESTful API resource, including:
- Eloquent Model with SoftDeletes & fillable setup
- Migration file with a
namecolumn and soft deletes support - API Controller with basic CRUD operations & pagination, filtering, sorting
- Form Request classes for validation with proper JSON error responses
Installation
Require the package via Composer:
composer require worksofallen/laravel-api-scaffold:v1.0.0 --dev
Publish the command if necessary (depends on how you package it).
Usage
Run the custom Artisan command to generate a full API scaffold for a resource:
php artisan make:api {name}
Replace {name} with the singular model name, e.g., Product, Category, etc.
What gets created?
app/Models/{Name}.php— Model with fillablenameattribute and soft deletes.database/migrations/xxxx_xx_xx_xxxxxx_create_{snake_plural}_table.php— Migration withnameand soft deletes columns.app/Http/Requests/{Name}StoreRequest.php— Validation request for storing.app/Http/Requests/{Name}UpdateRequest.php— Validation request for updating.app/Http/Controllers/API/{Name}Controller.php— API controller with:indexmethod supporting search (q), sort (sortField,sortOrder), and pagination (sizePerPage).store,show,update,destroymethods.
Features
- Standardized API scaffolding reduces repetitive boilerplate code.
- Soft deletes enabled by default.
- Search, sort, paginate support out of the box.
- JSON validation error responses for API-friendly error handling.
- Clean, maintainable, and easy to customize generated code.
Example
php artisan make:api Product
Generates Product API scaffolding:
- Model:
app/Models/Product.php - Migration:
database/migrations/xxxx_xx_xx_create_products_table.php - Requests:
ProductStoreRequest,ProductUpdateRequest - Controller:
app/Http/Controllers/API/ProductController.php
Authors
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
Please review our security policy on how to report security vulnerabilities.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.