2015年7月27日 星期一

使用Laravel artisan schedule:run時 exec被禁用時的替代方案

```php namespace App\Console; use Artisan; 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', ]; /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule */ protected function schedule(Schedule $schedule) { // 當exec被disabled時只要改成使用Artisan::call('command')即可 $schedule->call(function () { Artisan::call('inspire'); }) ->hourly(); } } ```