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