larapulse/sitemap-bundle
Composer 安装命令:
composer require larapulse/sitemap-bundle
包简介
Provides a way to generate a sitemap as well as for static and dynamic routes, which require Propel, Doctrine, etc.
README 文档
README
This Bundle provides a way to create a xml sitemap using any source you want (Doctrine, Propel, MongoDB, Faker, etc.).
This bundle aims to generate standards compliant sitemaps. For more information about sitemaps go to sitemaps.org.
The sitemap generation part is handled by the SitemapGenerator library, this bundle eases its integration into a Symfony2 application.
Main features
- static sitemap generation
- dynamic sitemap generation
- sitemap index generation
- memory efficient
- datasource independent
- support for media content (currently images and videos)
Install
Via Composer
$ composer require larapulse/sitemap-bundle
Register the SitemapBundle in app/AppKernel.php:
# app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Larapulse\SitemapBundle\LarapulseSitemapBundle(), ]; }
Configuration
Add the following options to app/config/config.yml file:
larapulse_sitemap: base_host: http://www.foo.com base_host_sitemap: http://www.foo.com limit: 50000
Note:
- The
base_hostwill be prepended to relative urls added to the sitemap. - The
base_host_sitemapwill be prepended to the sitemap filename (used for sitemap index) - The
limitis the number of url allowed in the same sitemap, if defined it will create a sitemap index
Routing
If you don't want to use the console to generate the sitemap, import the routes:
larapulse_sitemap: resource: "@LarapulseSitemapBundle/Resources/config/routing.yml"
This will make the sitemap available from the /sitemap.xml URL.
Usage
Add this line /web/sitemap.xml* to your .gitignore to prevent tracking sitemap.xml files by version control system.
Providers
In order to support any kind of datasource, the sitemap uses providers to fetch the data.
Exemple provider:
<?php namespace SitemapGenerator\Provider; use SitemapGenerator\Entity\Url; use SitemapGenerator\Provider\ProviderInterface; use SitemapGenerator\Sitemap\Sitemap; class CustomProvider implements ProviderInterface { public function populate(Sitemap $sitemap) { $url = new Url(); $url->setLoc('http://www.google.de'); $url->setChangefreq(Url::CHANGEFREQ_NEVER); $url->setLastmod('2012-12-19 02:28'); $sitemap->add($url); } }
All the providers implement the ProviderInterface, which define the
populate() method.
Note: so they can be automatically used by the sitemap, providers have to be
described in the DIC with the sitemap.provider tag:
services: sitemap_custom_provider: class: SitemapGenerator\Provider\CustomProvider tags: - { name: sitemap.provider }
All the services tagged as sitemap.provider will be used to generate the
sitemap.
Simple provider
A provider to add static routes into the sitemap easily.
parameters: sitemap.simple_options: routes: - {name: homepage} - name: foo params: {foo: bar} lastmod: '2017-11-23' changefreq: monthly priority: 0.5 # the following parameters are optionnal lastmod: '2015-01-01' changefreq: never priority: 0.2 services: sitemap_simple_provider: class: SitemapGenerator\Provider\SimpleProvider arguments: [ @router, %sitemap.simple_options% ] tags: - { name: sitemap.provider }
Propel provider
A propel provider is included in the bundle. It allows to populate a sitemap with the content of a table.
Here is how you would configure the provider:
# app/config/parameters.yml parameters: sitemap.propel_options: model: ACME\DemoBundle\Model\News # /news/{id} loc: {route: news_show, params: {id: slug}} # the following parameters are optionnal filters: ['filterByIsValid'] lastmod: date changefreq: daily priority: 0.2 # app/config/services.yml services: sitemap_propel_provider: class: SitemapGenerator\Provider\PropelProvider arguments: - "@router" - "%sitemap.propel_options%" tags: - { name: sitemap.provider }
Doctrine provider
A doctrine provider is included in the bundle. It allows to populate a sitemap with the content of a table.
Here is how you would configure the provider:
# app/config/parameters.yml parameters: sitemap.doctrine_options: entity: AcmeDemoBundle:News # /news/{id} loc: {route: news_show, params: {id: slug}} # the following parameters are optionnal query_method: findValidQuery lastmod: updatedAt changefreq: daily priority: 0.2 # app/config/services.yml services: sitemap_doctrine_provider: class: SitemapGenerator\Provider\DoctrineProvider arguments: - "@doctrine.orm.entity_manager" - "@router" - "%sitemap.doctrine_options%" tags: - { name: sitemap.provider }
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information. This project was forked from sitemap-php/KPhoenSitemapBundle
larapulse/sitemap-bundle 适用场景与选型建议
larapulse/sitemap-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 11 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「command」 「Sitemap」 「seo」 「symfony-bundle」 「larapulse」 「sitemap-bundle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 larapulse/sitemap-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 larapulse/sitemap-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 larapulse/sitemap-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Wrapper for exec and it's results
Symfony bundle to monitor and execute commands
Symfony sitemap generator
PHP Simple Sitemap Generator
Shell command module for PHP.
Interfaces for web resource models and services to retrieve and create them
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-11-23