Coder Social home page Coder Social logo

adambinnersley / sitemap Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 47 KB

Generate a XML sitemap for a given URL. This class crawls any given website to create an XML sitemap for the domain.

License: MIT License

PHP 85.86% XSLT 14.14%
xml-sitemap sitemap-generator sitemap sitemap-php sitemap-builder sitemapper

sitemap's Introduction

PHP XML Sitemap Generator

Generate a XML sitemap for a given URL. This class crawls any given website to create an XML sitemap for the domain.

Installation

Installation is available via Composer/Packagist, you can add the following line to your composer.json file:

"adamb/sitemap": "^1.0"

or

composer require adamb/sitemap

Usage

Example of usage can be found below:

// Method 1
$sitemap = new Sitemap\Sitemap('http://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false


// Method 2
$sitemap = new Sitemap\Sitemap();
$sitemap->setDomain('http://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false

Change file creation location

By default the sitemap.xml file is created in the document root but this can be altered using the following method.

$sitemap = new Sitemap\Sitemap('http://www.yourwebsite.co.uk');

// This should be an absolute path
$sitemap->setFilePath($_SERVER['DOCUMENT_ROOT'].'sitemaps/');

// or

$sitemap->setFilePath('C:\Inetpub\mywebsite.co.uk\httpdocs\sitemaps\\');

$sitemap->createSitemap();

Sitemap creation options

By default the sitemap creates a XSL stylesheet along with the sitemap. You can also change the level of the link to include in the sitemap (e.g. Only include links within 3 clicks of the homepage) and also change the filename of the sitemap on creation.

// To not include the XSL stylesheet set the first value to false when calling createSitemap();
$sitemap->createSitemap(false);

// To only include links within 3 click set the second value to 3
$sitemap->createSitemap(true, 3);

// To change the filename set the third value to your filename (excluding extension)
$sitemap->createSitemap(true, 5, 'mysitemapfile');

sitemap's People

Contributors

adambinnersley avatar

Watchers

 avatar  avatar  avatar

sitemap's Issues

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.