1
我在command.in文件夾中創建了一個新類App \ Console \ Commands;laravel:調度程序無法找到我的控制器
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Schedular extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'log:Schedular';
/**
* The console command description.
*
* @var string
*/
protected $description = 'schadular';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
return $schedule->call('[email protected]')->everyMinute();
}
}
,並在kern.php我寫了下面的代碼
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use \App\Controllers;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'App\Console\Commands\Schedular'
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
return $schedule->call('')->everyMinute();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
我應該寫在這裏的控制器類?或者我應該寫什麼?
return $schedule->call('')->everyMinute();
或者我應該創建一個新的類,它具有與控制器相同的功能?
控制器用於Web請求,您需要創建一個控制檯命令類 –
您確定要在這裏使用「受保護的函數」嗎? – Frondor