I am working in kernel command where I need to change the old commands:
Old Command is:
php artisan crawl:author
Now I need to rename it like:
php artisan crawl-bq:author
In my command file signature is changed like:
protected $signature = 'crawl-bq:author';
I cleaned the artisan cache using following command:
php artisan cache:clear
php artisan config:cache
Still my old command is working as well as new command is also working. But when I see the artisan list "php artisan list" then old commands are not seen there also.
Anybody there to help me?
The clear-compiled command is used to clear the compiled classes and services application cache.
To call another Artisan command and save its output you should use $this->call() from your command.
Press Ctrl + Shift + ESC. Locate the php process running artisan and kill it with right click -> kill process. Reopen the command-line and start back the server.
Old Command is:
php artisan crawl:author
Now we rename it like "crawl-bq:author"
php artisan crawl-bq:author (Will Work)
php artisan crawl-b:author (Will Work)
php artisan craw:author (Will Work)
php artisan crawl:author (Will Work)
Solution
Rename it with some other name like "newcrawl-bq:author"
php artisan crawl:author (Not work)
php artisan crawl-bq:author (Not work)
php artisan newcrawl-bq:author (Will work)
After a long time, I have come to state where I have found that Laravel 5.2 artisan console command has a bug or it is not bug as at least one command will be executed according to initial pattern matching.
Let assume, you have two signatures in two different command file like following 4 cases:
Case I:
protected $signature = 'crawl:author-usa';
protected $signature = 'crawl:author-uk';
OR Case II:
protected $signature = 'crawl:authorusa';
protected $signature = 'crawl:authoruk';
OR Case III:
protected $signature = 'crawl-bq:author-usa';
protected $signature = 'crawl-bq:author-uk';
OR Case IV:
protected $signature = 'crawl-bq:authorusa';
protected $signature = 'crawl-bq:authoruk';
For either case, if you run the php artisan crawl:auther
command then for Case I, it will show the ambiguous error like:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "crawl:author" is ambiguous (crawl:author-usa, crawl:author-uk).
It will show the same ambiguous message for the rest 3 cases but signature wise text would be different.
Now assume the following signature for 4 different cases:
Case I:
protected $signature = 'crawl:author-usa';
OR Case II:
protected $signature = 'crawl:authorusa';
OR Case III:
protected $signature = 'crawl-bq:author-usa';
OR Case IV:
protected $signature = 'crawl-bq:authorusa';
For either case, if you run the php artisan crawl:auther
command, it will execute that command.
For these two scenario, it is happening because of Symfony/Cconsole find() function. Here exact command is searched by this expression : crawl[^:]*[^:]*:author[^:]*[^:]*
. That means, if any signature has crawl<anything>:author<anything>
will match with php artisan crawl:author
Now if I come to the solution of this problem, primarily it needs to change public function find($name)
near 509 line at symfony/consle file. Or if there is a possibility to overwrite this function ( I am not sure how this override could be done ).
I was inspired by @Nadeem0035 where he mentioned the public function find($name)
near 509 line at symfony/consle file. I would have been happy if I could award the bounty in bounty time duration as at least he showed me a way to find exact scenario of console command. That is why a up vote dude :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With