xhallix
xhallix

Reputation: 3011

Laravel console command not working

trying to setup an example console command on laravel 5.2 but it's not working

I ran php artisan make:console CoolCommand

Here's my file

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class CoolCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'be:cool';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Allows you to be cool';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        echo "Yes you are very cool!";
    }
}

When I hit php artisan the command is not listed under the given signature

What am I missing? Thanks

Upvotes: 1

Views: 3341

Answers (1)

aynber
aynber

Reputation: 23011

If it's not listed when you type php artisan, you forgot to register the command as described here. Open app/Console/Kernel.php and enter your command.

 protected $commands = [
     Commands\CoolCommand::class
 ];

Upvotes: 2

Related Questions