Laravel Auto CRUD Generator is a package created by Abdelrahman Muhammed that streamlines CRUD operations in Laravel by generating all necessary files and logic for a model with a single command, saving time and effort.
Key Features
- Automatically detects models in the app/Models folder.
- Provides an interactive CLI to select a model.
- Generates controller, request validation, routes, views, and more.
- Follows Laravel's best practices for clean and maintainable code.
You can install this package via Composer:
composer require mrmarchone/laravel-auto-crud --dev
Next, publish the package's configuration:
php artisan vendor:publish --provider="Mrmarchone\LaravelAutoCrud\LaravelAutoCrudServiceProvider" --tag="auto-crud-config"
Finally, start generating your CRUD operations:
php artisan auto-crud:generate [options]
Some options include specifying the Model, selecting the type of application (e.g., api
or web
), generating CURL requests and Postman collections for an API, and more.
An example of some of these options could be:
php artisan auto-crud:generate --model=User --type=api --repository --curl --postman
The generate command above creates the following files already populated with code to get you started:
app/Http/Controllers/Api/UserController.php
app/Http/Requests/UserRequest.php
app/Http/Resources/UserResource.php
app/Http/Repositories/UserRepository.php
app/Http/Services/UserService.php
- Your
routes\api.php
file will be updated with an API Resource route defined laravel-auto-crud\curl.txt
with sample commands for each routelaravel-auto-crud\postman.json
with requests that you can import directly into Postman.
You can learn more about this package and view the source code on GitHub.