laravel 5.4 sitemap error

孤街浪徒 提交于 2019-12-25 01:58:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!