mr.incognito/crudify
Laravel package to scaffold API or web CRUD via Artisan. Generates models, migrations, controllers, form requests, resources, and optional Blade views. Supports typed validation, nullable fields (~), foreign keys/constraints, defaults, exclude flags, and a delete:crud cleanup command.
A Laravel package to quickly scaffold API or Web-based CRUD operations using a simple Artisan command. It generates Models, Migrations, Form Requests, API Resources, Controllers, and even Blade views — with full support for validation, foreign keys, nullable fields, and default values.
To install the package, run:
composer require mr.incognito/crudify
~ as a suffix)string, integer, boolean)php artisan make:crud ModelName --fields="field:type|rule1|rule2;another:foreign~|constrained:table" --type=api|web --exclude=model,..
php artisan make:crud Department --fields="name:string|max:255;created_by:foreign~|constrained:users"
php artisan make:crud Department --fields="name:string;created_by:foreign|constrained:users|onDelete:cascade"
php artisan make:crud Department --fields="name:string;created_by:foreign~|constrained:hospitals"
php artisan make:crud Department --fields="name:string;status:boolean~|default:true"
app/Models/Department.phpapp/Http/Controllers/DepartmentController.phpapp/Http/Requests/DepartmentRequest.phpapp/Http/Resources/DepartmentResource.phpdatabase/migrations/xxxx_xx_xx_create_departments_table.phproutes/api.phpphp artisan make:crud Article --fields="title:string;content:text" --type=web
resources/views/articles/*.blade.phpWeb\ArticleControllerweb.phpphp artisan make:crud Article --fields="title:string;content:text" --type=web --exclude=migration,model
resources/views/articles/*.blade.phpWeb\ArticleControllerweb.phpphp artisan make:crud Department --fields="name:string" --type=api --exclude=model,migration
Skips model and migration, still creates controller, request, and resource.
Use delete:crud to remove all files generated by make:crud for a given resource in one command. It is the exact reverse of make:crud.
php artisan delete:crud ModelName --type=api|web --exclude=model,.. --force
php artisan delete:crud Hospital
# Delete API CRUD files
php artisan delete:crud Hospital --type=api
# Delete Web CRUD files
php artisan delete:crud Hospital --type=web
php artisan delete:crud Hospital --force
Keep certain files while deleting the rest — useful when you want to preserve your model or migration history.
# Keep the model
php artisan delete:crud Hospital --exclude=model
# Keep the migration (recommended to preserve DB history)
php artisan delete:crud Hospital --exclude=migration
# Keep both model and migration
php artisan delete:crud Hospital --exclude=model,migration
# Keep the route entry
php artisan delete:crud Hospital --exclude=route
# Keep controller and resource
php artisan delete:crud Hospital --exclude=controller,resource
# Delete web CRUD, skip prompt, keep migration
php artisan delete:crud Hospital --type=web --exclude=migration --force
# Delete api CRUD, keep model and migration, no prompt
php artisan delete:crud Hospital --type=api --exclude=model,migration --force
| Component | API path | Web path |
|---|---|---|
model |
app/Models/Hospital.php |
app/Models/Hospital.php |
request |
app/Http/Requests/HospitalRequest.php |
app/Http/Requests/HospitalRequest.php |
migration |
database/migrations/*_create_hospitals_table.php |
database/migrations/*_create_hospitals_table.php |
controller |
app/Http/Controllers/Api/HospitalController.php |
app/Http/Controllers/Web/HospitalController.php |
resource |
app/Http/Resources/HospitalResource.php |
— |
views |
— | resources/views/hospitals/ (entire directory) |
route |
Strips entry from routes/api.php |
Strips entry from routes/web.php |
When run without --force, the command shows a preview and asks for confirmation before deleting anything:
The following files will be deleted for <Hospital> (api):
✗ [model] app/Models/Hospital.php
✗ [request] app/Http/Requests/HospitalRequest.php
✗ [migration] database/migrations/2024_01_01_000000_create_hospitals_table.php
✗ [controller] app/Http/Controllers/Api/HospitalController.php
✗ [resource] app/Http/Resources/HospitalResource.php
Are you sure you want to delete these files? (yes/no) [no]:
> yes
Deleted:
✓ [model] app/Models/Hospital.php
✓ [request] app/Http/Requests/HospitalRequest.php
✓ [migration] database/migrations/2024_01_01_000000_create_hospitals_table.php
✓ [controller] app/Http/Controllers/Api/HospitalController.php
✓ [resource] app/Http/Resources/HospitalResource.php
✓ [route] removed route entry from routes/api.php
API CRUD for Hospital deleted successfully.
If a file was not found it is reported as skipped rather than throwing an error:
Not found (skipped):
? [migration] database/migrations/*_create_hospitals_table.php
Each field uses the format:
column_name:data_type[~]|rules|default:xyz;next_column:foreignId[~]|constrained:table
You can use any of the following Laravel migration column types:
string, text, boolean, integer, decimal, date, uuid, json, timestamp, etc.
foreign, e.g., user_id:foreign~|constrained:users~, e.g., email:string~default:value, e.g., status:boolean|default:true| Modifier | Description |
|---|---|
~ |
Makes the field nullable |
default:value |
Sets a default value in the migration |
constrained |
Adds a foreign key constraint |
onDelete:CASCADE |
Adds delete behavior for foreign keys |
🎯 --type=api — generates API controller and resource only
🎯 --type=web — generates web controller and Blade views
✂️ --exclude=model,migration,... — skip generating specific components
🗑️ delete:crud — reverse any make:crud with a single command
If --type is not specified, the command defaults to type=api.
php artisan make:crud Book --fields="title:string;author:string"
This is equivalent to:
php artisan make:crud Book --fields="title:string;author:string" --type=api
By default, it generates API-related files:
api.phpThis package uses Pest for testing:
composer test
This package uses Rector for automated code refactoring and PHP/Laravel upgrades:
composer rector
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Sandeep Pant
This package is open-sourced software licensed under the MIT License.
How can I help you explore Laravel packages today?