Artisan Command Not Found in Laravel - Fix
This error occurs when trying to run an Artisan command that doesn't exist or when PHP/artisan isn't accessible.
The Error
Command not found / artisan: command not found
Common Causes
- 1 Not in Laravel project directory
- 2 Custom command not registered
- 3 PHP not in system PATH
- 4 Typo in command name
- 5 Command class has errors
Solutions
Ensure you're in project root
# Navigate to your Laravel project
cd /path/to/your/laravel/project
# Verify artisan exists
ls artisan
# List available commands
php artisan list
Register custom command
// app/Console/Kernel.php
protected $commands = [
\App\Console\Commands\YourCustomCommand::class,
];
// Or commands are auto-discovered from app/Console/Commands
Create a custom command
php artisan make:command SendEmails
// In app/Console/Commands/SendEmails.php
class SendEmails extends Command
{
protected $signature = 'mail:send {user}';
protected $description = 'Send emails to user';
public function handle()
{
$this->info('Sending emails...');
}
}
Clear and cache commands
# Clear cached commands
php artisan clear-compiled
# If commands still not found
composer dump-autoload
php artisan package:discover
Need Help With Your Laravel Project?
I specialize in building custom Laravel applications, process automation, and SaaS development. Whether you need to eliminate repetitive tasks or build something from scratch, let's discuss your project.
Currently available for 2-3 new projects
About Hafiz
Senior Full-Stack Developer with 9+ years building web apps and SaaS platforms. I build web applications with Laravel and Vue.js, and automate business processes. Creator of ReplyGenius, StudyLab, and other SaaS products.
View Portfolio