Giter VIP home page Giter VIP logo

sitemap's Introduction

Thepixeldeveloper\Sitemap

Author Build Status HHVM Status Software License Packagist Version Total Downloads SensioLabsInsight Scrutinizer Code Quality

A tool to generate XML sitemaps

Basic Usage

Generating a urlset sitemap

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

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

$urlSet->addUrl($url);

Generating a sitemapindex sitemap

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

$url = (new Thepixeldeveloper\Sitemap\Sitemap($loc))
  ->setLastMod($lastMod);
  
$sitemapIndex->addSitemap($url);

Then pass either SitemapIndex or Urlset to Output to generate output

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

Subelements

You can add more specific information to a URL entry, ie video / image information

Image

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

Video

$subelement = new Thepixeldeveloper\Sitemap\Subelements\Video('thumbnail', 'title', 'description');

Mobile

$subelement = new Thepixeldeveloper\Sitemap\Subelements\Mobile();

Link

$subelement = new Thepixeldeveloper\Sitemap\Subelements\Link('de', 'http://www.example.com/schweiz-deutsch/');

News

$subelement = (new Thepixeldeveloper\Sitemap\Subelements\News())
    ->setPublicationDate(new \DateTime())
    ->setPublicationLanguage('en')
    ->setPublicationName('Site Name')
    ->setTitle('Some title');

Then you need to add the subelement to the URL

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

and rendering is described above.

Advanced Usage

Indenting output

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

echo (new Thepixeldeveloper\Sitemap\Output())
    ->setIndented(false)
    ->getOutput($urlSet);

Configuration

Name Default Values
setIndented true boolean
setIndentString 4 spaces string

Why should I use this over cartographer?

  • This library has less complexity. All it's going to do is build an object graph and spit it out as XML
  • Has support for a growing list of sub elements ie: mobile and images
  • No dependencies. A library outputting XML doesn't need to rely on Flysystem

sitemap's People

Contributors

thepixeldeveloper avatar nicolas-brousse avatar masnathan avatar handybitesize avatar hkdobrev avatar johnblackmore avatar marcw avatar jacobemerick avatar

Watchers

James Cloos avatar Stephane avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.