Download the PHP package gpslab/sitemap without Composer
On this page you can find all versions of the php package gpslab/sitemap. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gpslab/sitemap
More information about gpslab/sitemap
Files in gpslab/sitemap
Package sitemap
Short Description sitemap.xml builder
License MIT
Homepage https://github.com/gpslab/sitemap
Informations about the package sitemap
Sitemap.xml Generation Framework
This is a framework for streaming build Sitemaps.xml and index of Sitemap.xml.
See Sitemap.xml protocol for more details.
Features
- Streaming build (saves RAM);
- Parallel multiple streaming;
- Specify localized URL version;
- Automatically calculate URL priority;
- Automatically calculate URL change frequency;
- Sitemap overflow tracking by total links;
- Sitemap overflow tracking by used size;
- Protocol compliance tracking;
- Compression in gzip and deflate;
- Build a Sitemap for a site section (not only the root
sitemap.xml
); - Groups URLs in several Sitemaps;
- Use URLs building services;
- Create a Sitemap with several URLs building services;
- Write a Sitemap to the file;
- Sends a Sitemap to the output buffer;
- Write a Sitemap index into the file;
- Split a Sitemap on overflow;
- Split a Sitemap on overflow and write a part of Sitemap into the Sitemap.xml index;
- Write a Sitemap to a temporary folder to save the valid
sitemap.xml
in the destination path during build; - Render a Sitemap by XMLWriter;
- Render a Sitemap as a plain text without any dependencies;
- Compressed or formatted XML;
- XML schema validation.
Group build
This is an example of how the sitemap.xml
can be build by your console command. In this example, all site links are
divided into groups and a build service is created for each group. In this example, a sitemap is build from 6675 links,
but this approach also facilitates the build of large site maps for 100000 or 500000 links.
Installation
Pretty simple with Composer, run:
Simple usage
Result sitemap.xml
:
Change frequency
How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page.
You can define it:
-
As string
-
As constant
- As object
Priority
The priority of this URL relative to other URLs on your site. Valid values range from 0.0
to 1.0
. This value does not
affect how your pages are compared to pages on other sites-it only lets the search bots know which pages you deem
most important for the search bots.
You can define it:
-
As string
-
As float
-
As integer
- As object
Localized versions of page
If you have multiple versions of a page for different languages or regions, tell search bots about these different variations. Doing so will help search bots point users to the most appropriate version of your page by language or region.
You can simplify the creation of URLs for localized versions of the same page within the same domain.
Result sitemap.xml
:
URL builders
You can create a service that will return a links to pages of your site.
It was a simple build. We add a builder more complicated.
We take one of the exists builders and configure it.
Sitemap index
You can create Sitemap index to group multiple sitemap files. If you have already created portions of the Sitemap, you can simply create the Sitemap index.
Result sitemap.xml
:
Split URLs and make Sitemap index
You can simplify splitting the list of URLs to partitions and creating a Sitemap index.
You can push URLs into the WritingSplitIndexStream
stream and he will write them to the partition of the Sitemap.
Upon reaching the partition size limit, the stream closes this partition, adds it to the index and opens the next
partition. This simplifies the building of a big sitemap and eliminates the need for follow size limits.
You'll get a Sitemap index sitemap.xml
and a few partitions sitemap1.xml
, sitemap2.xml
, sitemapN.xml
from a
large number of URLs.
As a result, you will get a file structure like this:
Result sitemap.xml
:
Split URLs in groups
You may not want to break all URLs to a partitions like with WritingSplitIndexStream
stream. You might want to make
several partition groups. For example, to create a partition group that contains only URLs to news on your website, a
partition group for articles, and a group with all other URLs.
This can help identify problems in a specific URLs group. Also, you can configure your application to reassemble only individual groups if necessary, and not the entire map.
Note. The list of partitions is stored in the WritingSplitStream
stream and a large number of partitions
will spend memory.
As a result, you will get a file structure like this:
Streams
MultiStream
- allows to use multiple streams as one;WritingStream
- useWriter
for write a Sitemap;WritingIndexStream
- writes a Sitemap index withWriter
;WritingSplitIndexStream
- split list URLs to sitemap parts and write its withWriter
to a Sitemap index;WritingSplitStream
- split list URLs and write its withWriter
to a Sitemaps;OutputStream
- sends a Sitemap to the output buffer. You can use it in controllers;LoggerStream
- use PSR-3 for log added URLs.
You can use a composition of streams.
Streaming to file and compress result without index.
Streaming to file and output buffer.
Writer
FileWriter
- write a Sitemap to the file;TempFileWriter
- write a Sitemap to the temporary file and move in to target directory after finish writing;GzipFileWriter
- write a Sitemap to the file compressed by gzip;GzipTempFileWriter
- write a Sitemap to the temporary file compressed by gzip and move in to target directory after finish writing.DeflateFileWriter
- write a Sitemap to the file compressed by deflate;DeflateTempFileWriter
- write a Sitemap to the temporary file compressed by deflate and move in to target directory after finish writing.
Render
If you install the XMLWriter PHP extension, you can use
XMLWriterSitemapRender
and XMLWriterSitemapIndexRender
. Otherwise you can use PlainTextSitemapRender
and
PlainTextSitemapIndexRender
who do not require any dependencies and are more economical.
The location of Sitemap file
The Sitemap protocol imposes restrictions on the URLs that can be specified in it, depending on the location of the Sitemap file:
- All URLs listed in the Sitemap must use the same protocol (
https
, in this example) and reside on the same host as the Sitemap. For instance, if the Sitemap is located athttps://www.example.com/sitemap.xml
, it can't include URLs fromhttp://www.example.com/
orhttps://subdomain.example.com
. - The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file
located at
https://example.com/catalog/sitemap.xml
can include any URLs starting withhttps://example.com/catalog/
but can not include URLs starting withhttps://example.com/news/
. - If you submit a Sitemap using a path with a port number, you must include that port number as part of the path in
each URL listed in the Sitemap file. For instance, if your Sitemap is located at
http://www.example.com:100/sitemap.xml
, then each URL listed in the Sitemap must begin withhttp://www.example.com:100
. - A Sitemap index file can only specify Sitemaps that are found on the same site as the Sitemap index file. For
example,
https://www.yoursite.com/sitemap_index.xml
can include Sitemaps onhttps://www.yoursite.com
but not onhttp://www.yoursite.com
,https://www.example.com
orhttps://yourhost.yoursite.com
.
URLs that are not considered valid may be dropped from further consideration by search bots. We do not check these restrictions to improve performance and because we trust the developers, but you can enable checking for these restrictions with the appropriate decorators. It is better to detect a problem during the sitemap build process than during indexing.
ScopeTrackingStream
-Stream
decorator;ScopeTrackingSplitStream
-SplitStream
decorator;ScopeTrackingIndexStream
-IndexStream
decorator.
The decorators takes the stream to decorate and the sitemap scope as arguments.
License
This bundle is under the MIT license. See the complete license in the file: LICENSE
All versions of sitemap with dependencies
ext-mbstring Version *