Run Artisan command from a button

I just upgraded an old project from October 1 to 2. I have a button in a controller than, when pressed, runs this code:


This doesn’t work after the update, I get the error "“The command “realestate:xmlimport” does not exist.” on line 181 of C:\wamp64\www\finquesgrau\vendor\laravel\framework\src\Illuminate\Console\Application.php

The command is correctly registered in the Plugin.php register method, and it runs perfectly from the command line. What should I do to be able to call artisan commands from a controller?

Hey @Maria_UtopigStudio

It sounds like the command isn’t registered in the context of the Artisan call. Just to make sure, try running to see if it makes any difference:


It says that the command october:about doesn’t exist (neither in the command line, I think that it doesn’t exist in october v2), but if I run Artisan::call(‘october:migrate’), it works ok

Ok, so check where the command is registered, make sure that code is running.

// ...
trace_log('I am running -- found in storage/logs/system.log');

It is possible the code won’t run if the plugin is missing dependencies. That would be my best guess.

this is interesting too : [Solved] Laravel Artisan, The Command Does Not Exist · Nono Martínez Alonso


1 Like

Ok I found it. The problem was in the command definition:

protected $name = 'realestate:xmlimport {filename?}';

It should be

protected $signature = "realestate:xmlimport {filename?}';

I checked that it has to be like this both in OC2 and OC3. The doc for OC2 is not correct Development - October CMS - 2.x (it is ok for OC3)

It’s curious that if I only remove the param it works with $name also, the problem only arises when there are optional arguments, this works:
protected $name = 'realestate:xmlimport';

1 Like

If you added the argument to the call method, it should work

Artisan::call(‘realestate:xmlimport filename.csv’);