Я добавил spatie / laravel-sitemap в свое приложение Laravel, и он работает, когда я запускаю команду php artisan sitemap: generate, но я не могу понять, как заставить его работать автоматически с расписанием Kernel.php.
Я добавил команду $ schedule-> ('sitemap: generate') -> hourly ();но он не работает
Консоль / Команды / GenerateSitemap.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Spatie\Sitemap\SitemapGenerator;
class GenerateSitemap extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $signature = 'sitemap:generate';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate the sitemap.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// modify this to your own needs
SitemapGenerator::create('mywebsite')
->writeToFile(public_path('sitemap.xml'));
}
}
Консоль \ Kernel.php
<?php
namespace App\Console;
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 = [
Commands\GenerateSitemap::class,
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('sitemap:generate')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
Что нужно добавить, чтобы он автоматически генерировалсякарта сайта каждый час?