mohammad-zarifiyan/laravel-sitemap-manager
Composer 安装命令:
composer require mohammad-zarifiyan/laravel-sitemap-manager
包简介
A Laravel package for managing sitemaps.
README 文档
README
Sitemap Manager is a Laravel package for automated sitemap generation and management. It creates new sitemap files, replaces outdated ones, and keeps everything up to date using a single Artisan command and Laravel’s scheduler.
Ideal for Laravel applications that need reliable, repeatable, and automated sitemap handling.
Installation
Install the package via Composer:
composer require mohammad-zarifiyan/laravel-sitemap-manager:^3.0
Database Migrations
This package stores sitemap metadata in the database.
Publish and run the migrations:
php artisan vendor:publish --provider="MohammadZarifiyan\LaravelSitemapManager\Providers\SitemapManagerProvider" --tag="sitemap-manager-migrations"
php artisan migrate
Configuration
To publish the configuration file:
php artisan vendor:publish --provider="MohammadZarifiyan\LaravelSitemapManager\Providers\SitemapManagerProvider" --tag="sitemap-manager-config"
Routes
Register the package routes in your routes/web.php file:
use Illuminate\Support\Facades\Route; Route::sitemap();
This code registers sitemap serving routes.
Scheduling
To keep sitemaps updated automatically, register the command in Laravel’s scheduler:
use Illuminate\Support\Facades\Schedule; Schedule::command('sitemap-manager:refresh-sitemaps')->daily();
Make sure your server cron is configured to run Laravel’s scheduler.
How It Works
- Sitemap data is collected from all registered registries.
- Sitemap files are generated in chunks based on the configured
tags-per-sitemaplimit. - Existing sitemap files are safely replaced with the new ones.
- Metadata about generated sitemaps is stored in the database.
- Your sitemaps are served dynamically at the
/sitemap.xmlpath, automatically adapting to your domain.
Creating a Custom Sitemap Registry
Sitemap Manager allows you to add your own data sources by implementing the MohammadZarifiyan\LaravelSitemapManager\Interfaces\RegistryInterface or MohammadZarifiyan\LaravelSitemapManager\Interfaces\RestrictedRegistryInterface.
This document explains how to create a custom registry, handle pagination, and register it in the configuration.
1. Implement RegistryInterface
Create a new class that implements MohammadZarifiyan\LaravelSitemapManager\Interfaces\RegistryInterface:
<?php namespace App\Sitemaps; use MohammadZarifiyan\LaravelSitemapManager\Interfaces\RegistryInterface; use App\Models\Post; use Spatie\Sitemap\Tags\Url; use Generator; class PostRegistry implements RegistryInterface { public function getName(): string { return 'posts'; } public function tags(): Generator { $posts = Post::query() ->where('published', true) ->cursor(); foreach ($posts as $post) { yield Url::create('http://localhost/blog/' . $post->slug); } } }
Notes:
getName() returns a unique name for your registry.
tags() should return a \Generator.
2. Implement RestrictedRegistryInterface (Optional)
If your sitemap needs domain restrictions, implement MohammadZarifiyan\LaravelSitemapManager\Interfaces\RestrictedRegistryInterface:
<?php namespace App\Sitemaps; use MohammadZarifiyan\LaravelSitemapManager\DataTransferObjects\Domain; use MohammadZarifiyan\LaravelSitemapManager\Interfaces\RestrictedRegistryInterface; use Illuminate\Support\Collection; use Illuminate\Support\LazyCollection; use MohammadZarifiyan\LaravelSitemapManager\Enums\SitemapRestrictionType; use Spatie\Sitemap\Tags\Url; use Generator; class RestrictedPostRegistry implements RestrictedRegistryInterface { public function getName(): string { return 'restricted-posts'; } public function tags(): Generator { yield Url::create('https://localhost/first'); yield Url::create('https://localhost/second'); } public function domains(): Collection|LazyCollection { // Return allowed or prohibited domains return collect([ new Domain('example.com'), new Domain('another-site.com'), ]); } public function restrictionType(): SitemapRestrictionType { return SitemapRestrictionType::Prohibition; } }
3. Register Your Registry in Configuration
Open your config/sitemap-manager.php and add your registry class to the registries array:
<?php return [ // rest of your configuration file 'registries' => [ \App\Sitemaps\PostRegistry::class, \App\Sitemaps\RestrictedPostRegistry::class, ], // rest of your configuration file ];
mohammad-zarifiyan/laravel-sitemap-manager 适用场景与选型建议
mohammad-zarifiyan/laravel-sitemap-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 73 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Sitemap」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mohammad-zarifiyan/laravel-sitemap-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mohammad-zarifiyan/laravel-sitemap-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mohammad-zarifiyan/laravel-sitemap-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony sitemap generator
PHP Simple Sitemap Generator
Interfaces for web resource models and services to retrieve and create them
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Sitemap and sitemap index builder for Jigsaw.
Sitemap for seo
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2026-01-30