1. Go to this page and download the library: Download webit/sitemap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webit / sitemap example snippets
namespace MyProject;
use Webit\Sitemap\Exposer\UrlExposerInterface;
use Webit\Sitemap\UrlSet;
use Webit\Sitemap\Url;
class MyExposer implements UrlExposerInterface
{
/**
* @return UrlSet
*/
public function getUrlSet()
{
$urlSet = new UrlSet();
$urlSet->addUrl(Url::create('http://my-project.domain/url-1'));
$urlSet->addUrl(Url::create('http://my-project.domain/url-2'));
$urlSet->addUrl(Url::create('http://my-project.domain/url-3'));
// add urls you need
return $urlSet;
}
}
use Webit\Sitemap\Writer\SerializerUrlSetWriter;
use Webit\Sitemap\Provider\SitemapProvider;
/** @var \JMS\Serializer\SerializerInterface $serializer **/
$writer = new SerializerUrlSetWriter($serializer, sys_get_temp_dir());
$exposer = new MyProject\MyExposer();
$provider = new SitemapProvider($exposer, $writer, 7, '/dir/inside/your/project/can/be/webroot');
/**
* Generate XML file (\SplFileInfo instance)
*/
$sitemapFile = $provider->getSitemap();
// if you need to force regeneration use
$sitemapFile = $provider->getSitemap(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.