davidpersson/indexed

Increase and control index-ability of your site; PHP library for generating sitemaps and controlling all the robots.

v1.1.0 2014-06-10 10:59 UTC

This package is not auto-updated.

Last update: 2024-12-21 17:34:52 UTC


README

_ _  _ ___  ____ _  _ ____ ___
| |\ | |  \ |___  \/  |___ |  \
| | \| |__/ |___ _/\_ |___ |__/
-- Increase and control index-ability of your site.

Synopsis
--------
A PHP library for generating sitemaps and controlling all the robots.

Features
--------
- Sitemap XML with full schema definitions
- Generate sitemaps and siteindexes
- Support for images in sitemaps
- Enforces sitemap size constraints
- All directives from Robots Exclusion Standard 1.0
- All directives from Robots Exclusion Standard 2.0
- Additional support for unofficial 'Sitemap' and 'Crawl-Delay' extensions

Usage
-----
Creating XML for sitemap with images:
<?php

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 required.
$sitemap->page('/post/know-the-cat');

// Images are also supported and can be added to existing pages.
$sitemap->image('/img/kittykat.png', '/post/know-the-cat', [
    'title' => 'My favorite Cat',
    'location' => 'Hamburg, Germany'
]);

$xml = $sitemap->generate();

?>

Creating a siteindex:
<?php

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();

?>

Control all the lovely robots:
<?php

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();

?>

Copyright & License
-------------------
Indexed is Copyright (c) 2013-2014 David Persson if not otherwise stated.
The code is distributed under the terms of the BSD 3-clause License. For
the full license text see the LICENSE file.

Installation
------------
The preferred installation method is via composer. You can add the library
as a dependency via:

$ composer require davidpersson/indexed

Running the Tests
-----------------
This library is continously integrated. Please check the following URL
for information on the status of the latest builds:

http://travis-ci.org/#!/davidpersson/indexed

Tests for this library are PHPUnit based. To run the tests you'll need
to have PHPUnit installed[1]. Following command will run all the tests.

$ phpunit

[1] http://www.phpunit.de/manual/current/en/installation.html