Laravel 4 任务计划不工作
Laravel 4 Task Scheduling not working
我正在使用 laravel 4,我想使用我在 https://laravel.com/docs/master/scheduling#introduction 找到的任务计划,但由于某些原因它不起作用。
user@ASUS c:\xampp\htdocs\ski\theskitrip\protected
# php artisan schedule:run
[InvalidArgumentException]
There are no commands defined in the "schedule" namespace.
user@ASUS c:\xampp\htdocs\ski\theskitrip\protected
我只是想知道,因为我已经按照文档进行操作,所以我创建了 .../app/Console/Kernel.php
,这是 Kernel.php
的内容
<?php
namespace App\Console;
use DB;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('tb_applicants')->insert(array('fullname' => "Mar Binay", 'email' => "asdsad@sdfsdf.dsf"));
})->everyMinute();
}
}
有人知道我的案子吗?我不想使用 cron,因为它很棘手。
请问,是否需要在php artisan中创建类似这样的调度? https://laravel.com/docs/master/artisan
Task Scheduling 可从 Laravel 5 获得,因此如果您写的是您正在使用 Laravel 4 - 它根本不起作用!
另外 .../app/Console/Kernel.php
- LAravel 4 尚不支持此文件。
我正在使用 laravel 4,我想使用我在 https://laravel.com/docs/master/scheduling#introduction 找到的任务计划,但由于某些原因它不起作用。
user@ASUS c:\xampp\htdocs\ski\theskitrip\protected
# php artisan schedule:run
[InvalidArgumentException]
There are no commands defined in the "schedule" namespace.
user@ASUS c:\xampp\htdocs\ski\theskitrip\protected
我只是想知道,因为我已经按照文档进行操作,所以我创建了 .../app/Console/Kernel.php
,这是 Kernel.php
<?php
namespace App\Console;
use DB;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
\App\Console\Commands\Inspire::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->call(function () {
DB::table('tb_applicants')->insert(array('fullname' => "Mar Binay", 'email' => "asdsad@sdfsdf.dsf"));
})->everyMinute();
}
}
有人知道我的案子吗?我不想使用 cron,因为它很棘手。
请问,是否需要在php artisan中创建类似这样的调度? https://laravel.com/docs/master/artisan
Task Scheduling 可从 Laravel 5 获得,因此如果您写的是您正在使用 Laravel 4 - 它根本不起作用!
另外 .../app/Console/Kernel.php
- LAravel 4 尚不支持此文件。