did you add artisan to your profile on your local machine?
to be on the safe side you can always do something like this in your cronjob
php /var/www/com/website/artisan task:run
When I upgraded to 4.1 I had the same problem. In my start/artisan.php i had $artisan->add(...) instead of Artisan::add(...). I would guess it was a typo from my part, but it might come from some tutorial/docs somewhere and since 4.1 there is no object in $artisan (at least not at the point that file is loaded).
Edit: was curious, and i was right: the tutorial is here: http://code.tutsplus.com/tutorials/your-one-stop-guide-to-laravel-commands--net-30349
Thanks for your reactions. Any help is welcome :-)
@Zenry: i'm not sure I understand what I should do. The cronjob I'm trying to run is "php artisan command:daily-maintenance" (this is the same command that was working with laravel 4.0). This comes back with log that command unknown. To check I defined a cronjob "php artisan" which results in an overview of all artisan commands that are available. To me that looked like confirmation that the artisan command is working but just isn't loading the custom commands. Why it's not seeing the custom commands is unknown to me.
@Chris: I did have that problem before and corrected it in the way you stated. My command in artisan.php is: Artisan::add(new DailyMaintenanceCommand()); On my local environment it's all working (which wasn't the case when I still had the $artisan->add syntax), so I think the code is ok. I think it must be some configuration somewhere but I'm don't know for sure
Still, no solution to that? I got the same issue and have spend hours researching stackoverflow and various laravel forums...
Any idea greatly appreciated.
Further info: Here is what I have found in the meantime:
if have done php artisan dump-autoload and if I do:
php artisan list
I see all, but my custom command. I have ensured that app/start/artisan.php is executed, by ading a dd('I am here'); statement, which I have removed after successfully proven that it worked. Then I did the same inside the constructor of my custom command, so that also gets executed when artisan is called.
Yet the command does not show in the list and I also cannot call it (artisan returns the
[InvalidArgumentException]
There are no commands defined in the "acp" namespace.
Does anyone know how to test artisan to get to the bottom of this problem?
I'm currently looking for this solution as well. Has anyone found it yet?
use /usr/local/bin/php instead of php alone for instance
/usr/local/bin/php /var/www/com/website/artisan task:run
WhiteHatCoder said:
use /usr/local/bin/php instead of php alone for instance
/usr/local/bin/php /var/www/com/website/artisan task:run
WhiteHatCoder, that actually solved this problem. Thanks!
Can you explain, why I was not able to see custom commands when call artisan using: php /path/to/laravel/artisan mytask ?
When you run cron jobs, the ENV path variable is usually not defined. If you run only "php artisan something" it can't find the php executable. I had to do "/usr/local/bin/php /var/www/artisan". Another thing you could do is to set the path in the crontab file itself. Ie, add something like this:
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community