I deployed my Laravel application to cPanel. On my local environment, running:

php artisan leaves:credit-monthly

works 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 list

the 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-autoload

Still, 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?

hmm's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.