As I near the completion of my first Laravel project I thought I would share some of the commands which I found most useful and which helped noticably speed up my development. This is aimed at people at a similar level of experience to myself – those just starting to work with Laravel and who would like to get off to the best start.
When starting out with a project Laravels artisan commands will be used to provide the majority of the scaffolding to your project. You will find yourself running the following commands over and over again, even with a relatively small project:
If you know a certain model – lets be original and call it Posts – will require a migration and a controller, instead of repeating the above 3 commands for each, Laravel offers a much more succinct way of achieving this.
Adding the -mc option will automatically generate a migration and a controller along with the Model and save precious seconds.
Note: Bare in mind here that your controller may not follow the naming conventions of Laravel and you may have to change this to its plural form.
As well as this, I often find myself creating a controller with the same CRUD functions and found this fairly repetitive. If you wish to create a resourceful controller you can simply add -r to the end of your make command and it will add the necessary boilerplate to the generated controller where you can then trim away any unneeded functions – again saving valuable seconds.
You can, of course, use this in conjunction with the above using the following command.
To those looking to get to grips with the fundamentals of Laravel I suggest having a look at the Laravel from Scratch course on Laracasts. Jeffrey Way helps guide you through at a pace that allows everything to really sink in, without allowing it to get tedious.