14

I have created a custom command called confirmUserCommand with the filename matching the class name (same case). The $name is set to confirmuser.

Running the command php artisan list displays the new command on my local, but not on the server (which is running linux). I did perform a composer dump-autoload and update the relevant composer files to no avail.

Any suggestions please?

maximus 69
  • 1,388
  • 4
  • 22
  • 35

5 Answers5

30

Laravel 5.2 ~ 5.5:

Create your command & edit

   protected $signature = 'order:check'; //or whatever you want your command to be

You will have to find where the commands are created & edit the app\Console\kernel.php file.

in this file under

protected $commands = [
    \App\Console\Commands\OrderCheck::class,
]

run again

 php artisan list 

It should be listed there :)

George
  • 6,886
  • 3
  • 44
  • 56
A H Bensiali
  • 825
  • 1
  • 9
  • 22
3

In newer versions of Laravel it's not longer needed to register the commands, just be sure that the console command class name is the same as the file that hosts it.

App/Console/Commands/MyCommand.php -> class MyCommand ...

  • Indeed! In my case the problem was my class name was singular, but class file name was plural and thus not matching. – М.Б. May 06 '22 at 10:19
1

Just tore my hair out and found out the issue..

In order to list the artisan commands including the custom ones, you have to invoke the systems PHP CLI Intepreter specifically PHP call.

php artisan list : would list all the commands as expected but not the custom commands you created

php-cli artisan list : This would list the all commands including the custom commands created

Hope this helps someone and save their hair :)

lukasgeiter
  • 147,337
  • 26
  • 332
  • 270
maximus 69
  • 1,388
  • 4
  • 22
  • 35
1

From laravel version 5.6 onwards you need not make the entry of your custom command in app\Console\kernel.php

YDF
  • 365
  • 5
  • 9
-1

In order to make it appear in the php artisan list you need to add it to the App/http/Kernel.php file specifically in the commands array:

 protected $commands = [
   'App\Console\CreateSlugsCommand',....
];

After you do that you can run in your console php artisan list and you you will see the custom command.

Luis Mata B.
  • 312
  • 3
  • 8