问题
I want to install this package in my project https://github.com/spatie/laravel-sitemap
but the installation's failed. the error is
Anyone encountered this error. or their have other better package for laravel sitemap? any tutorial? thanks everyone :)
回答1:
The error message is pretty clear. You're trying to install spatie/laravel-sitemap:^3.3
, which requires laravel/framework:5.5
or higher. So you need to either upgrade to use Laravel 5.5, or use an older version of spatie/laravel-sitemap
.
The Github repository lists the available releases. I would suggest looking at v2.4
as a starting point, as the ChangeLog for v3.0
mentions about adding Laravel 5.5 support.
composer require spatie/laravel-sitemap:2.4
Edit:
You asked where to put the generator code. It isn't something you're going to want to run on every request, so I would suggest creating a route dedicated to creating the sitemap.
// routes/web.php
Route::get('sitemap/generate', function () {
SitemapGenerator::create(base_url())->writeToFile($path);
});
来源:https://stackoverflow.com/questions/47586415/laravel-5-4-sitemap-error