Command no exception defined

I created a team with Artisan

$ php artisan command:make NeighborhoodCommand 

This created the file app/commands/NeighborhoodCommand.php

Code snippet. I changed the value of name and populated the fire() function

 <?php use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; class NeighborhoodCommand extends Command { protected $name = 'neighborhood'; public function fire() { // my code } } 

But then when I try to run the command with

 $ php artisan neighborhood 

I get this error:

 [InvalidArgumentException] Command "neighborhood" is not defined. 
+7
command laravel laravel-4
source share
1 answer

Laravel 5.5 +

https://laravel.com/docs/5.5/artisan#registering-commands

If you want, you can continue to manually register your teams. But L5.5 gives you the ability to lazily load them. If you are upgrading from an old version, add this method to your kernel:

 /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } 

Laravel 5

http://laravel.com/docs/5.4/artisan#registering-commands

Modify the app/Console/Kernel.php and add the command to the $commands array:

 protected $commands = [ Commands\NeighborhoodCommand::class, ]; 

Laravel 4

http://laravel.com/docs/4.2/commands#registering-commands

Add this line to app/start/artisan.php :

 Artisan::add(new NeighborhoodCommand); 
+23
source share

All Articles