tahsingokalp / laravel-sitemap
Laravel 站点地图生成器
v11.0.2
2024-03-22 21:35 UTC
Requires
- php: ^8.0
- illuminate/filesystem: ^8.0 || ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/framework: ^8.0 || ^9.0 || ^10.0 || ^11.0
- laravel/pint: ^1.14
- orchestra/testbench: ^9.0.0||^8.22.0
- orchestra/testbench-core: ^6.0 || ^7.0 || ^8.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- php-coveralls/php-coveralls: ^2.2
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-22 22:35:43 UTC
README
Laravel Sitemap
这是一个仅适用于 Laravel 8、9 和 10 的Laravelium/laravel-sitemap分支。原始仓库已被放弃。
需要 PHP ^8.0
。
安装
如果 laravelium/sitemap
已作为项目的一部分存在
composer remove laravelium/sitemap
则运行
composer require tahsingokalp/laravel-sitemap
php artisan vendor:publish --provider="TahsinGokalp\Sitemap\SitemapServiceProvider"
生成一个简单的站点地图
Route::get('mysitemap', function() { $sitemap = resolve("sitemap"); $sitemap->add(URL::to(), '2012-08-25T20:10:00+02:00', '1.0', 'daily'); $sitemap->add(URL::to('page'), '2012-08-26T12:30:00+02:00', '0.9', 'monthly'); $posts = DB::table('posts')->orderBy('created_at', 'desc')->get(); foreach ($posts as $post) { $sitemap->add($post->slug, $post->modified, $post->priority, $post->freq); } // generate (format, filename) // sitemap.xml is stored within the public folder $sitemap->store('xml', 'sitemap'); });
示例
更多内容请参考Wiki。