Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here

Want an inspirational quote? There's Artisan command for that!

Web-development is not all serious - there are some fun activities too. So let's have a break from mega-urgent code writing and get some inspiration. From our beloved Artisan - with a command "inspire".

It's not officially documented, but if you run php artisan inspire, you will get a random motivational quote right in your terminal. Like this.

screen-shot-2016-12-29-at-12-11-04-pm

How does it work? Well, if you ever looked at /routes folder, there are three files there:

  • web.php - the one we generally use
  • api.php - for projects with API
  • console.php - this one is interesting for us now!

Let's take a look at routes/console.php:

use Illuminate\Foundation\Inspiring;

/*
|--------------------------------------------------------------------------
| Console Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of your Closure based console
| commands. Each Closure is bound to a command instance allowing a
| simple approach to interacting with each command's IO methods.
|
*/

Artisan::command('inspire', function () {
    $this->comment(Inspiring::quote());
});

This is where we find that inspire command, and actually - the whole console.php file concept, which is not documented properly, is about routing your artisan commands like this, instead of going through app/Console/Kernel.php.

Is it really usable? Good question, since it's not really documented - I guess, Taylor didn't pay too much attention to it (maybe in the future?), so for now it's just a cool little thing to know.

I hope it inspires you for the upcoming 2017!

No comments or questions yet...

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 67 courses (1172 lessons, total 43 h 18 min)
  • 90 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent New Courses