botalaszlo / symfony-repositemap-bundle
RepoSiteMapbundle是一个symfony 2的bundle,可以从静态URL和实体仓库中创建sitemap.xml。
Requires
- php: >=5.5.9
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- sensio/framework-extra-bundle: ^3.0.2
- symfony/symfony: 3.0.*
Requires (Dev)
- phpunit/phpunit: 5.1.*@stable
This package is not auto-updated.
Last update: 2024-09-14 19:36:41 UTC
README
RepoSiteMapbundle是一个symfony 2的bundle,可以从静态页面和从动态页面(如帖子、文章、产品详情页面)中创建sitemap.xml,因此该bundle将为每个实体视图页面生成URL。
##要求(最低)
- PHP 5.3.0
- Symfony 2.3.0
- @Route注解
您也可以在composer.json中找到这些要求。
##安装 将bundle添加到根目录的composer.json
文件中。
"require": {
//...
"botalaszlo/symfony-repositemap-bundle": "dev-master"
}
在app/AppKernel.php
中的RegisterBundle
函数中添加bundle。
public function registerBundles()
{
$bundles = array(
//...
new RepoSiteMapBundle\RepoSiteMapBundle(),
);
}
在app/config.yml
中的routing.yml
中添加bundle。
# RepoSiteMap Bundle
RepoSiteMapBundle:
resource: @RepoSiteMapBundle/Controller/
type: annotation
##使用 对于使用,您必须使用@Route注解。###静态页面 您必须在@Route注解的options
中添加"sitemap"=true
值。这将为Home控制器中的index操作生成一个URL。
/**
*
* @Route("/home/index ", name="AppBundle_home_index", options={"sitemap"=true})
*/
public function indexAction() {
//...
}
###动态页面 如果您有实体的视图页面,例如"posts"、"articles"、"products",则必须在options中添加实体的路径。因此,该bundle将为每个实体的详细视图动态生成URL。使用此格式:"sitemap" = {"repository" = "[[EntityPath]]"
/**
* @Route("/product/{id} ", name="AppBundle_product", options={"sitemap" = {"repository" = "AppBundle:Slip"}})
*/
public function listAction() {
//...
}
在这种情况下,您需要添加实体的路径。然后,bundle将统计表中的实体数量,以了解表中有多少行。因此,它将为每个实体动态生成视图页面。
##待办事项 此bundle的功能非常有限。它不处理sitemap URL的日期、频率或优先级值。这些功能将在未来实现。
如果您有任何建议,请随时告知我。