PHP code example of creativefactoryrv / cartographer

1. Go to this page and download the library: Download creativefactoryrv/cartographer 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/ */

    

creativefactoryrv / cartographer example snippets

 php
use CreativeFactoryRV\Cartographer\ChangeFrequency;
use CreativeFactoryRV\Cartographer\Sitemap;

$sitemap = new Sitemap();
$sitemap->add('http://foo.com', '2005-01-02', ChangeFrequency::WEEKLY, 1.0);
$sitemap->add('http://foo.com/about', '2005-01-01');

// Write it to a file
file_put_contents('sitemap.xml', (string) $sitemap);

// or simply echo it:
header ('Content-Type:text/xml');
echo $sitemap->toString();
 php
$sitemapIndex = new CreativeFactoryRV\Cartographer\SitemapIndex();

$sitemapIndex->add('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');

// Write it to a file
file_put_contents('sitemap.xml', (string) $sitemapIndex);

// or simply echo it:
header ('Content-Type:text/xml');
echo $sitemapIndex->toString();
 php


use CreativeFactoryRV\Cartographer\SitemapFactory;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;

$adapter = new LocalFilesystemAdapter(__DIR__ . '/sitemaps');
$filesystem = new Filesystem($adapter);

$sitemapFactory = new SitemapFactory($filesystem);
 php
$sitemapFactory->setBaseUrl('http://foo.com/sitemaps/');
 php
$files = $sitemapFactory->getFilesCreated();