timwassenburg / laravel-improved-resource-controllers
Generate complete resource controllers
Requires (Dev)
- orchestra/testbench: ^6.19
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-12-08 01:29:54 UTC
README
Table of Contents
Features
This simple package extends the php artisan make:controller
command and generates
resource controllers with working resource functions out of the box to prevent you from writing
the same basic controller functions over and over again.
Keep in mind the improved resource controllers are only meant as a starting point.
You still have to add your own routes, validation, migrations, etc.
Getting started
Installation
Require the package with composer.
composer require timwassenburg/laravel-improved-resource-controllers --dev
Publish config (optional)
php artisan vendor:publish --provider="TimWassenburg\ImprovedResourceControllers\ImprovedResourceControllersServiceProvider" --tag="config"
Publish stubs (optional)
To change the generated resource controllers you can override the stubs and adjust it to your liking. The stubs will be stored in /resources/stubs.
php artisan vendor:publish --provider="TimWassenburg\ImprovedResourceControllers\ImprovedResourceControllersServiceProvider" --tag="stubs"
Usage
The idea behind this package is that you can keep using the make:controller commands you are already used to. So no need to change your muscle memory. Checkout the example output to see the result for each command.
Default resource controller
php artisan make:controller CustomerController --resource
Default API resource controller
php artisan make:controller CustomerController --resource --api
Model resource controller
php artisan make:controller CustomerController --resource --model=Customer
Model API resource controller
php artisan make:controller CustomerController --resource --model=Customer --api
Nested resource controller
php artisan make:controller CityController --resource --parent=Country --model=City
Nested API resource controller
php artisan make:controller CityController --resource --parent=Country --model=City --api
Variables
In the stubs you can use the following variables.
General
With parent (--parent=Customer)
More generator packages
Looking for more ways to speed up your workflow? Make sure to check out these packages.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
The MIT License (MIT). Please see License File for more information.