2017 © Pedro Peláez
 

symfony-bundle sitemap-xml-bundle

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

image

evheniy/sitemap-xml-bundle

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

  • Wednesday, October 21, 2015
  • by evheniy
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10,070 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 4 % Grown

The README.md

SitemapXmlBundle

This bundle provides sitemap.xml generator for Symfony2, (*1)

knpbundles.com, (*2)

Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Build Status Coverage Status Scrutinizer Code Quality Build Status, (*4)

Installation

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

Or add to composer.json, (*5)

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

AppKernel:, (*6)

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 ), (*7)

The easy way to create sitemap:, (*8)

<?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:, (*9)

<?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, (*10)

app/console sitemap:dump

Documentation

SitemapXmlBundle made by using fluent interface:, (*11)

$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:, (*12)

License

This bundle is under the MIT license., (*13)

Документация на русском языке, (*14)

Demo, (*15)

Build a sitemap, (*16)

The Versions

21/10 2015

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sitemap sitemap.xml google standards

15/10 2015

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

symfony sitemap sitemap.xml google standards