Access all tutorials in sprocket icon.
Published April 3, 2016 by Bill Keck.
Bonus Material for Laraboot: Laravel 5.2 For Beginners Released
Chapter 11: How to make a custom Artisan command
I’m happy to announce the release today of another chapter of bonus material for Laraboot: Laravel 5.2 For Beginners. This is a quick chapter to knock out how to create a custom artisan command.
All updates and bonus material are free to anyone who has purchased the book, just log into your leanpub account and pull down the latest copy.
I found myself in a slightly embarrassing situation where I was demonstrating traits and forgot to include the php open tag in the file. On top of that, I messed up the folder location. When that happened, I realized how much I love the code generators from Artisan, which help prevent these kinds of mistakes.
With artisan, a simple command line instruction gets me a perfectly formatted controller, model, middleware, request, event, etc., whenever I need it. It’s just awesome.
So I thought, wouldn’t it be cool to have an artisan command that stubs out a trait? And then I thought this would make a great tutorial as well. However, when I implemented, it was just too much for the blog. As it is, it ended up being 15 pages in the book. While none of it is especially complicated, I was very thorough in my explanations. That brings the page count to the book to 496 pages.
Anyway, writing the custom artisan command was a wonderful experience because it showed me once again how easy and intuitive Laravel really is. The docs clear and helpful. I was amazed that it that it works so well with so little effort.
That’s not the first time I’ve fallen in love with the framework. It seems to happen again and again. Laravel is the leading PHP framework and it deserves to be.