Skip to content

Commit

Permalink
Merge pull request #12 from ThePixelDeveloper/develop
Browse files Browse the repository at this point in the history
Version 4
  • Loading branch information
ThePixelDeveloper committed Dec 18, 2015
2 parents 0fb93d5 + d3c1343 commit c6fb3e8
Show file tree
Hide file tree
Showing 36 changed files with 1,904 additions and 395 deletions.
5 changes: 4 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
.travis.yml export-ignore
phpspec.yml export-ignore
/spec export-ignore
/.idea export-ignore
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
composer.lock
composer.phar
vendor
.idea/
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: php

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

before_script:
- composer install --dev --prefer-source
- composer install

script: phpunit
script: vendor/bin/phpspec run
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
99 changes: 99 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
Thepixeldeveloper\Sitemap
=========================

[![Author](http://img.shields.io/badge/author-@colonelrosa-blue.svg)](https://twitter.com/colonelrosa)
[![Build Status](https://img.shields.io/travis/ThePixelDeveloper/Sitemap-v2/master.svg)](https://travis-ci.org/ThePixelDeveloper/Sitemap-v2)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
[![Packagist Version](https://img.shields.io/packagist/v/thepixeldeveloper/sitemap.svg)](https://packagist.org/packages/thepixeldeveloper/sitemap)
[![Total Downloads](https://img.shields.io/packagist/dt/thepixeldeveloper/sitemap.svg)](https://packagist.org/packages/thepixeldeveloper/sitemap)
[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/ed6d56e8-c908-44dc-9154-a8edc8b168bc.svg)](https://insight.sensiolabs.com/projects/ed6d56e8-c908-44dc-9154-a8edc8b168bc)

A tool to generate XML sitemaps

Basic Usage
-----

Generating a urlset sitemap

``` php
$urlSet = new Thepixeldeveloper\Sitemap\Urlset();

foreach ($entities as $entity) {
$url = new Thepixeldeveloper\Sitemap\Url($loc);
$url->setLastMod($lastMod);
$url->setChangeFreq($changeFreq);
$url->setPriority($priority);

$urlSet->addUrl($url);
}
```

Generating a sitemapindex sitemap


``` php
$sitemapIndex = new Thepixeldeveloper\Sitemap\SitemapIndex();

foreach ($entities as $entity) {
$url = new Thepixeldeveloper\Sitemap\Sitemap($loc);
$url->setLastMod($lastMod);

$sitemapIndex->addUrl($url);
}
```

Then pass either SitemapIndex or Urlset to `Output` to generate output


``` php
echo (new Thepixeldeveloper\Sitemap\Output())->getOutput($sitemapIndex);
```

Advanced Usage
--------------

**Indenting output**

Output is indented by default, can be turned off as follows

``` php
echo (new Thepixeldeveloper\Sitemap\Output())
->setIndented(false)
->getOutput($sitemapIndex);
```

Configuration

Name | Default | Values
---- | ------- | ------
setIndented | true | boolean
setIndentString | 4 spaces | string


**Google Images**

``` php
$urlset = new Thepixeldeveloper\Sitemap\Urlset();
$image = new Thepixeldeveloper\Sitemap\Subelements\Image('https://s3.amazonaws.com/path/to/image');

$url = (new Thepixeldeveloper\Sitemap\Url('http://www.example.com/1'))
->addSubelement($image);

$urlset->addUrl($url);

echo (new Thepixeldeveloper\Sitemap\Output())->getOutput($urlset);
```

Output

``` xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://www.example.com/1</loc>
<image:image>
<image:loc>https://s3.amazonaws.com/path/to/image</image:loc>
</image:image>
</url>
</urlset>
```
44 changes: 0 additions & 44 deletions README.mdown

This file was deleted.

11 changes: 4 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@
}
],
"require-dev": {
"phpunit/phpunit": "3.7.13"
},
"require": {
"php": ">=5.3.0"
"phpspec/phpspec": "^2.4"
},
"autoload": {
"psr-0": {
"Sitemap": "src"
"psr-4": {
"Thepixeldeveloper\\Sitemap\\": "src/"
}
}
}
}
Loading

0 comments on commit c6fb3e8

Please sign in to comment.