Properties

$sitemapFileName

$sitemapFileName : string

Name of sitemap file

Type

string

$sitemapIndexFileName

$sitemapIndexFileName : string

Name of sitemap index file

Type

string

$robotsFileName

$robotsFileName : string

Robots file name

Type

string

$maxURLsPerSitemap

$maxURLsPerSitemap : integer

Quantity of URLs per single sitemap file.

According to specification max value is 50.000. If Your links are very long, sitemap file can be bigger than 10MB, in this case use smaller value.

Type

integer

$createGZipFile

$createGZipFile : boolean

If true, two sitemap files (.xml and .xml.gz) will be created and added to robots.txt.

If true, .gz file will be submitted to search engines. If quantity of URLs will be bigger than 50.000, option will be ignored, all sitemap files except sitemap index will be compressed.

Type

boolean

$baseURL

$baseURL : string

URL to Your site.

Script will use it to send sitemaps to search engines.

Type

string

$basePath

$basePath : string

Base path. Relative to script location.

Use this if Your sitemap and robots files should be stored in other directory then script.

Type

string

$classVersion

$classVersion : string

Version of this class

Type

string

$searchEngines

$searchEngines : array

Search engines URLs

Type

array — of strings

$urls

$urls : array

Array with urls

Type

array — of strings

$sitemaps

$sitemaps : array

Array with sitemap

Type

array — of strings

$sitemapIndex

$sitemapIndex : array

Array with sitemap index

Type

array — of strings

$sitemapFullURL

$sitemapFullURL : string

Current sitemap full URL

Type

string

Methods

__construct()

__construct(string  $baseURL, string|null  $basePath = "") 

Constructor.

Parameters

string $baseURL

You site URL, with / at the end.

string|null $basePath

Relative path where sitemap and robots should be stored.

addUrls()

addUrls(  $urlsArray) 

Use this to add many URL at one time.

Each inside array can have 1 to 4 fields.

Parameters

$urlsArray

addUrl()

addUrl(string  $url, string  $lastModified = null, string  $changeFrequency = null, string  $priority = null) 

Use this to add single URL to sitemap.

Parameters

string $url

URL

string $lastModified

When it was modified, use ISO 8601

string $changeFrequency

How often search engines should revisit this URL

string $priority

Priority of URL on You site

createSitemap()

createSitemap() 

Create sitemap in memory.

toArray()

toArray() : array

Returns created sitemaps as array of strings.

Use it You want to work with sitemap without saving it as files.

Returns

array —

of strings

writeSitemap()

writeSitemap() 

Will write sitemaps as files.

updateRobots()

updateRobots() 

If robots.txt file exist, will update information about newly created sitemaps.

If there is no robots.txt will, create one and put into it information about sitemaps.

submitSitemap()

submitSitemap(string  $yahooAppId = null) : array

Will inform search engines about newly created sitemaps.

Google, Ask, Bing and Yahoo will be noticed. If You don't pass yahooAppId, Yahoo still will be informed, but this method can be used once per day. If You will do this often, message that limit was exceeded will be returned from Yahoo.

Parameters

string $yahooAppId

Your site Yahoo appid.

Returns

array —

of messages and http codes from each search engine

_writeFile()

_writeFile(string  $content, string  $filePath, string  $fileName) : boolean

Save file.

Parameters

string $content
string $filePath
string $fileName

Returns

boolean

_writeGZipFile()

_writeGZipFile(string  $content, string  $filePath, string  $fileName) : boolean

Save GZipped file.

Parameters

string $content
string $filePath
string $fileName

Returns

boolean