Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

Latest commit

 

History

History
41 lines (31 loc) · 1.04 KB

README.md

File metadata and controls

41 lines (31 loc) · 1.04 KB

SitemapServiceProvider for Silex

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.