ARTICLE AD BOX
I deployed my Laravel application to cPanel. On my local environment, running:
php artisan leaves:credit-monthlyworks perfectly.
I then set up a cron job in cPanel to run this command, but I get the error:
ERROR There are no commands defined in the "leaves" namespace.Interestingly, when I run in my localhost:
php artisan listthe leaves:credit-monthly command does appear in the list.
My setup:
Laravel custom command is in app/Console/Commands/CreditMonthlyLeaves.php
Kernel.php loads commands using:
php protected function commands(): void { $this->load(__DIR__.'/Commands'); }What I’ve tried:
Verified the command exists on the server Cleared Laravel caches (php artisan config:clear, cache:clear, etc.) Checked capitalization — server is Linux, so it is case-sensitive Ran composer dump-autoloadStill, the cron fails with the “no commands” error.
Question:
What could cause a Laravel command to work locally but not via a cPanel cron, even though it shows up in php artisan list? How can I make it run reliably in cPanel?
Explore related questions
See similar questions with these tags.
