havramar / next-php-sitemap-generator
Yet another sitemap generator in PHP.
Installs: 6 335
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 3
Open Issues: 0
Requires (Dev)
- mikey179/vfsstream: v1.2.0
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2020-01-06 03:55:59 UTC
README
Yet another sitemap generator in PHP.
Why?
Needed more customizable sitemap generator:
- switch format output,
- create only index files basing on config input,
- helper constants for some values,
- some other :)
Adding to existing project
composer require havramar/next-php-sitemap-generator:dev-master
How to run
- Get composer
curl -sS https://getcomposer.org/installer | php
- Install dependencies
php composer.phar install
- Create example script
example.php
<?php require_once 'vendor/autoload.php'; $sitemapCreator = new \SitemapGenerator\SitemapCreator(); $sitemapCreator->setDomain('http://www.example.com'); $url = new \SitemapGenerator\Url(); $url->loc = '/home'; $url->changefreq = \SitemapGenerator\Url::FREQ_HOURLY; $sitemapCreator->addUrl($url); $indexCreator = $sitemapCreator->buildIndexCreator(); $indexCreator->createIndex('http://www.example.com/sitemaps/');
- Run example
php example.php
- Two files were created in current directory
-
sitemap-1.xml
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/home</loc> <changefreq>hourly</changefreq> </url> </urlset>
-
sitemap-index-1.xml
<?xml version="1.0" encoding="UTF-8"?> <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>http://www.example.com/sitemaps/sitemap-1.xml</loc> </sitemap> </sitemapindex>
More examples
More examples can be found in tests file.
How to run tests
vendor/bin/phpunit --configuration tests