PHP code example of davidpersson / indexed

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

    

davidpersson / indexed example snippets



use indexed\Sitemap;

// All URLs a relative to the base given here.
$sitemap = new Sitemap('http://example.org');

$sitemap->page('/', [
    'changes' => 'daily',
    'priority' => '1.0'
]);

// Just the URL parameter is actually any'
]);

$xml = $sitemap->generate();



use indexed\Siteindex;

$siteindex = new Siteindex('http://example.org');

$siteindex->sitemap('/sitemap-0.xml');
$siteindex->sitemap('/sitemap-1.xml');
$siteindex->sitemap('/sitemap-2.xml');

$xml = $siteindex->generate();



use indexed\Robots;

$robots = new Robots();

// The following directives apply to all agents.
$robots->disallow('/admin');
$robots->requestRate(20);
$robots->sitemap('http://example.org/sitemap.xml');

// Disallow crawling of the entire site just for Google's AdsBot.
$robots->disallow('/', 'AdsBot-Google');

$txt = $robots->generate();