keiii/silex-sitemap

This package is abandoned and no longer maintained. No replacement package was suggested.

Provides service for generate sitemap.xml

2.0.1 2016-12-05 07:55 UTC

This package is not auto-updated.

Last update: 2023-03-04 10:29:16 UTC


README

Build Status

Provides sitemap-php service for Silex microframework.

Installation

composer require keiii/silex-sitemap

How to use

<?php

require_once __DIR__.'/vendor/autoload.php';

$app = new \Silex\Application();
$app->register(new \KEIII\SilexSitemap\SitemapServiceProvider(), array(
    'sitemap.domain' => 'http://example.com',
    'sitemap.path' => __DIR__,
    'sitemap.loc' => 'http://example.com/',
));

/** @var \KEIII\SilexSitemap\Sitemap $sitemap */
$sitemap = $app['sitemap'];

for ($i = 0; $i < 51000; $i++) {
    $item = (new \KEIII\SilexSitemap\SitemapItem())
        ->setLoc('/')
        ->setPriority(1.0)
        ->setChangefreq('daily')
        ->setLastmod(new \DateTime())
    ;
    $sitemap->addItem($item);
}

$sitemap->create();

When you run your script, it generates and saves XML files to given path.