keiii / silex-sitemap
Provides service for generate sitemap.xml
Installs: 6 465
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- evert/sitemap-php: ^1.2
- silex/silex: ^2.0
This package is not auto-updated.
Last update: 2023-03-04 10:29:16 UTC
README
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.