Reputation: 61
I'm using Laravel 5.3. I have wrote 2 laravel commands but when I call they from the window's cmd, just one works fine(command:name), the other(command:delayedPayment) gives me the next error:
But when I comment the DelayedPayment call, it works fine.
app/Console/Kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
'App\Console\Commands\GenerateInvoice',
'App\Console\Commands\DelayedPayment',
];
protected function schedule(Schedule $schedule)
{
$schedule->command('command:name')->everyMinute();
$schedule->command('command:delayedPayment')->everyMinute();
}
protected function commands()
{
require base_path('routes/console.php');
}
}
app/Console/Commands/DelayedPayment.php
namespace App\Console\Commands;
namespace App\Http\Business;
namespace App\Http\Entities;
use Illuminate\Console\Command;
class DelayedPayment extends Command
{
protected $signature = 'command:delayedPayment';
protected $description = 'Command description';
public function __construct()
{
parent::__construct();
}
public function handle()
{
...
}
}
Its necessary to do something else?.Thank you in advance!
Upvotes: 1
Views: 1838
Reputation: 2748
Whenever you see ReflextionException in Laravel, check your namespaces at first.
Upvotes: 2
Reputation: 13699
As according to your code, you've mentioned 3 namespaces inside DelayedPayment.php
file, you should mention only one namespace per file at the top:
namespace App\Console\Commands; // <-------- Use only one namespace per file
use Illuminate\Console\Command;
class DelayedPayment extends Command
{
protected $signature = 'command:delayedPayment';
protected $description = 'Command description';
public function __construct()
{
parent::__construct();
}
public function handle()
{
...
}
}
Read more about PHP Namespacing Docs
Upvotes: 2