Customize Laravel Stubs and save a lot of time
Víctor Falcón
Posted on April 22, 2021
Did you know that it's possible to customize Laravel stubs, so you can make a new controller, and it will be created in your own way?
Video in Spanish 🇪🇸
Publish and customize your stubs
The first thing that you have to do to customize your stubs it's publishing the default templates that comes with Laravel. You just need to run this artisan command:
artisan stub:publish
This will generate a new folder in resoureces/stubs
with all the default templates.
In that folder you can change any of them and it will be used every time you run an artisan make command of any kind.
How to create your own crontollers?
With each file type we have only one option, buy with controller we can create as much as we want. As you can see we can find a lot of controller.{type}.php
files in the stub folder. We can customize each of them or create new ones.
For example, if we create a controller.custom.php
then we can use this stub with:
artisan make:controller UserController --type=custom
Posted on April 22, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.