2017 © Pedro Peláez
 

library sitemap

Web-IT Sitemap Lib

image

webit/sitemap

Web-IT Sitemap Lib

  • Saturday, January 27, 2018
  • by dbojdo
  • Repository
  • 1 Watchers
  • 0 Stars
  • 80 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

Web-IT Site Map Generator

This library provides components to generate sitemap.xml file according to http://www.sitemaps.org, (*1)

Installation

Composer: add the webit/sitemap into composer.json

{
    "require": {
        "php": ">=5.6.0",
        "webit/sitemap": "^2.0.0"
    }
}

Usage

Prepare your implementation of a \Webit\Sitemap\Exposer\UrlExposerInterface. Its method getUrlSet must return instance of a \Webit\Sitemap\UrlSet object (which is a container for \Webit\Sitemap\Url objects)., (*2)

namespace MyProject;

use Webit\Sitemap\Exposer\UrlExposerInterface;
use Webit\Sitemap\UrlSet;
use Webit\Sitemap\Url;

class MyExposer implements UrlExposerInterface
{
    /**
     * @return UrlSet
     */
    public function getUrlSet()
    {
        $urlSet = new UrlSet();

        $urlSet->addUrl(Url::create('http://my-project.domain/url-1'));
        $urlSet->addUrl(Url::create('http://my-project.domain/url-2'));
        $urlSet->addUrl(Url::create('http://my-project.domain/url-3'));
        // add urls you need

        return $urlSet;
    }
}

Configure a SitemapProvider and generate a Site Map, (*3)

use Webit\Sitemap\Writer\SerializerUrlSetWriter;
use Webit\Sitemap\Provider\SitemapProvider;

/** @var \JMS\Serializer\SerializerInterface $serializer **/

$writer = new SerializerUrlSetWriter($serializer, sys_get_temp_dir());

$exposer = new MyProject\MyExposer();

$provider = new SitemapProvider($exposer, $writer, 7, '/dir/inside/your/project/can/be/webroot');

/**
 * Generate XML file (\SplFileInfo instance)
 */
$sitemapFile = $provider->getSitemap();

// if you need to force regeneration use
$sitemapFile = $provider->getSitemap(true);

The Versions

27/01 2018

dev-master

9999999-dev http://www.web-it.eu

Web-IT Sitemap Lib

  Sources   Download

MIT Web-IT

The Requires

 

The Development Requires

sitemap web-it

27/01 2018

0.11.x-dev

0.11.9999999.9999999-dev http://www.web-it.eu

Web-IT Sitemap Lib

  Sources   Download

MIT Web-IT

The Requires

 

sitemap web-it