承接 evheniy/sitemap-xml-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

evheniy/sitemap-xml-bundle

最新稳定版本:1.0.0

Composer 安装命令:

composer require evheniy/sitemap-xml-bundle

包简介

The SitemapXmlBundle adds the ability to generate sitemap.xml file to your application.

README 文档

README

This bundle provides sitemap.xml generator for Symfony2

knpbundles.com

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status Coverage Status Scrutinizer Code Quality Build Status

Installation

$ composer require evheniy/sitemap-xml-bundle "1.*"

Or add to composer.json

"evheniy/sitemap-xml-bundle": "1.*"

AppKernel:

public function registerBundles()
    {
        $bundles = array(
            ...
            new Evheniy\SitemapXmlBundle\SitemapXmlBundle(),
            new AppBundle\AppBundle(),
            ...
        );
        ...
...

You should set bundle before main bundle (in our example it's AppBundle) and extend SiteMapDumpCommand ( setEntities() method )

The easy way to create sitemap:

<?php

namespace AppBundle\Command;

use Evheniy\SitemapXmlBundle\Command\SiteMapDumpCommand as Command;

class SiteMapDumpCommand extends Command
{
    protected function setEntities()
    {
        $this->siteMapEntity = $this->serviceManager->createSiteMapEntity();
        $this->dumpEntity->setDomain('site.com');
        foreach ($pages as $page) {
            $this->siteMapEntity
                ->addLocation(
                    $this->serviceManager->createLocationEntity()
                        ->setLocation($page['url'])
                        ->setLastmod(new \DateTime($page['date']))
                );
        }
    }
}

If there are more than 50 000 links you should use sitemap index:

<?php

namespace AppBundle\Command;

use Evheniy\SitemapXmlBundle\Command\SiteMapDumpCommand as Command;

class SiteMapDumpCommand extends Command
{
    protected function setEntities()
    {
        $this->siteMapIndexEntity = $this->serviceManager->createSiteMapIndexEntity();
        $this->dumpEntity->setDomain('site.com');
        $siteMapEntity = $this->serviceManager->createSiteMapEntity();
        foreach ($pages as $page) {
            $siteMapEntity->addLocation(
                $this->serviceManager->createLocationEntity()
                    ->setLocation($page['url'])
                    ->setLastmod(new \DateTime($page['date']))
            );
        }
        $this->siteMapIndexEntity->addSiteMap($siteMapEntity);
    }
}

The last step

app/console sitemap:dump

Documentation

SitemapXmlBundle made by using fluent interface:

$this->siteMapIndexEntity
    ->addSiteMap(
        $this->serviceManager->createSiteMapEntity()
            ->addLocation(
                $this->serviceManager->createLocationEntity()
                    ->setLocation('http://site.com/page1.html')
                    ->setLastmod(new \DateTime())
            )
            ->addLocation(
                $this->serviceManager->createLocationEntity()
                    ->setLocation('http://site.com/page2.html')
                    ->setLastmod(new \DateTime())
                    ->addImage(
                        $this->serviceManager->createImageEntity()
                            ->setLocation('http://site.com/logo.png')
                            ->setTitle('Logo')
                    )
            )
    );

More details:

License

This bundle is under the MIT license.

Документация на русском языке

Demo

Build a sitemap

统计信息

  • 总下载量: 18.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固