onepkg / laravel-crud-generator
Laravel CRUD Generator
v1.0.6
2025-06-23 07:57 UTC
Requires
- php: ^7.3|^8.0
- laravel/framework: ^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- laravel/pint: ^1.22
- mockery/mockery: ^1.6
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.2
README
Laravel CRUD Generator is a simple command line tool to generate CRUD operations for your models.
app/
├── Http/
│ ├── Controllers/
│ │ └── Api/
│ │ └── {Model}Controller.php # RESTful controller
│ ├── Requests/
│ │ └── {Model}Request.php # Form request
│ ├── Resources/
| | └── {Model}Collection.php # JSON collection
│ │ └── {Model}Resource.php # JSON resource
├── Models/
│ └── {Model}.php # Model
└── Routes/
└── api.php # API route
Usage
Install the package via composer:
composer require --dev onepkg/laravel-crud-generator
Run the command:
- Generate CRUD files for the users table:
php artisan onepkg:make-crud User
- If the table name is not in the plural form
php artisan onepkg:make-crud User --table=user
- Specify the routing file
php artisan onepkg:make-crud User --route=api
Access the API
GET /api/users # get listing
POST /api/users # create
GET /api/users/{id} # show detail
PUT /api/users/{id} # update
DELETE /api/users/{id} # delete
Config
- Publish the config file
php artisan vendor:publish --provider="Onepkg\LaravelCrudGenerator\LaravelCrudServiceProvider"
- Modify the configuration
You can modify the configuration in /config/crud - generator.php
[ 'namespacedModel' => 'App\\Models', 'namespacedRequest' => 'App\\Http\\Requests\\Admin', 'namespacedResource' => 'App\\Http\\Resources\\Admin', 'namespacedController' => 'App\\Http\\Controllers\\Admin', ]
Customize stubs
Publish the stubs
php artisan stub:publish
Modify the corresponding stubs in /stubs/*.
controller.crud.stub
model.crud.stub
request.crud.stub
resource-collection.crud.stub
resource.crud.stub
route.crud.stub