nucleos / seo-bundle
Seo 组件
1.5.0
2024-08-14 16:27 UTC
Requires
- php: ^8.1
- ext-json: *
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/simple-cache: ^1.0 || ^2.0 || ^3.0
- sonata-project/block-bundle: ^4.21 || ^5.0
- symfony/config: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/form: ^6.4 || ^7.0
- symfony/framework-bundle: ^6.4 || ^7.0
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/options-resolver: ^6.4 || ^7.0
- twig/twig: ^2.9 || ^3.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.0.1
- knplabs/knp-menu: ^3.0
- knplabs/knp-menu-bundle: ^3.0
- symfony/browser-kit: ^6.4 || ^7.0
- symfony/filesystem: ^6.4 || ^7.0
- symfony/finder: ^6.4 || ^7.0
- symfony/phpunit-bridge: ^7.0
- symfony/yaml: ^6.4 || ^7.0
This package is auto-updated.
Last update: 2024-09-14 20:20:17 UTC
README
NucleosSeoBundle 是基于尊重 BC 的 SonataSeoBundle 的分支,它还提供了已废弃的 NucleosSitemapBundle 的站点地图功能。
安装
打开命令行控制台,进入您的项目目录,并执行以下命令以下载此库的最新稳定版本。
composer require nucleos/seo-bundle
启用 Bundle
然后,将 Bundle 添加到项目 config/bundles.php
文件中已注册的 Bundle 列表中以启用它。
// config/bundles.php return [ // ... Nucleos\SeoBundle\NucleosSeoBundle::class => ['all' => true], ];
配置 Bundle
创建一个名为 nucleos_seo.yaml
的配置文件
# config/routes/nucleos_seo.yaml nucleos_seo: resource: '@NucleosSeoBundle/Resources/config/routing/sitemap.yml' prefix: /
如果您想使用 symfony 缓存,您应该定义一个新的缓存池(PSR 6)并创建一个适配器将其映射到简单的缓存(PSR 16)。
nucleos_seo: cache: service: 'sitemap.cache.simple' framework: cache: pools: sitemap.cache: adapter: cache.app default_lifetime: 60 services: sitemap.cache.simple: class: 'Symfony\Component\Cache\Psr16Cache' arguments: - '@sitemap.cache'
添加静态条目
您可以在 yaml 配置中添加静态条目。
# config/packages/nucleos_seo.yaml nucleos_seo: static: - { url: 'http://example.com', priority: 75, changefreq: 'weekly' }
添加自定义站点地图
如果您想创建自定义站点地图,您只需创建一个使用 Nucleos\SeoBundle\Sitemap\SitemapServiceInterface
的服务,并使用 nucleos_seo.sitemap
标签服务。
<service id="App\Sitemap\CustomSitemap"> <tag name="nucleos_seo.sitemap"/> </service>
许可证
此 Bundle 在 MIT 许可证 下。