maxence / sitemap-generator
This package is abandoned and no longer maintained.
No replacement package was suggested.
There is no license information available for the latest version (v1.0.2) of this package.
Little library to automate generation of sitemaps in xml
v1.0.2
2018-06-13 23:07 UTC
Requires
- php: >= 7.0.0
This package is auto-updated.
Last update: 2020-08-29 06:53:51 UTC
README
Installation
Composer
Install the composer package by running the following command:
composer require maxence/sitemap-generator
Manual
- Download the "Source code" from the latest release
- Include
SitemapGen.php
Example
Add URL to the sitemap
For this example, we suppose the sitemap contain :
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> </urlset>
PHP
$path = path_to_sitemap.xml; $sitemap = new SitemapGen($path); $sitemap->add('htt://example.com/article/eat-frogs', time(), 'never', 1.0);
Result
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://example.com/article/eat-frogs</loc> <lastmod>2018-06-14</lastmod> <changefreq>never</changefreq> <priority>1</priority> </url> </urlset>
Delete URL to the sitemap
For this example, we suppose the sitemap contain the previous result.
PHP
$path = path_to_sitemap.xml; $sitemap = new SitemapGen($path); $sitemap->delete('htt://example.com/article/eat-frogs');
Result
<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> </urlset>
Functions
As you see in the example part, this package propose 2 functions ->add()
and ->delete()
-
->add()
: This function needs 4 parameters, these 4 parameters are the important informations to use in sitemaps, for more information, go to the sitemap doc.- url
- lastUpdate
- frequency
- priority
-
->delete
: This function needs 1 parameters- url