-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ThePixelDeveloper/develop
Version 4
- Loading branch information
Showing
36 changed files
with
1,904 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
composer.lock | ||
composer.phar | ||
vendor | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.