Download the PHP package kri55h/php-sitemapper without Composer
On this page you can find all versions of the php package kri55h/php-sitemapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kri55h/php-sitemapper
More information about kri55h/php-sitemapper
Files in kri55h/php-sitemapper
Package php-sitemapper
Short Description php-sitemapper: A lightweight and powerful PHP library for generating dynamic XML sitemaps effortlessly. Designed to help developers enhance their website's SEO by creating search-engine-friendly sitemaps, this tool is perfect for small and large-scale projects alike.
License MIT
Homepage https://github.com/KRI55H/php-sitemapper
Rated 5.00 based on 1 reviews
Informations about the package php-sitemapper
SiteMapper
SiteMapper is a lightweight, chainable PHP library to generate SEO-friendly XML sitemaps dynamically.
Designed for modern PHP projects and frameworks (Laravel, Codeigniter, Symfony, plain PHP).
Features
- Fluent API:
addUrl(...)->save()
for concise, readable code. - Add per-URL metadata:
priority
,lastmod
andchangefreq
. generateXml()
returns an XML string ready to return from controllers.outputXml()
sends correct headers and echoes XML directly.saveToFile()
writes sitemap XML to disk.- Minimal dependencies — requires only PHP and SimpleXML.
Requirements
- PHP 7.4 or newer
ext-simplexml
enabled
Installation
Install via Composer:
Then autoload:
Quick Example (recommended)
Important: addUrl()
stages a URL in memory. Call save()
to commit the staged entry into the sitemap list — otherwise it will not appear in generateXml()
.
Full Example (all functions / backwards-compatible style)
Public API Reference
-
addUrl(string $location, ?float $priority = null, ?string $last_modified = null, ?string $change_frequency = null): self
Adds a staged URL entry. Pass a full URL (https://example.com/page). Returns $this for chaining. -
setPriority(float $priority): self
Set priority (0.0 — 1.0) for the currently staged entry. Chainable. -
setLastModified(string $last_modified): self
Set the last modified date (YYYY-MM-DD) for the currently staged entry. Chainable. -
setChangeFrequency(string $change_frequency): self
Set change frequency (always|hourly|daily|weekly|monthly|yearly|never). Chainable. -
save(): self
Commit the currently staged entry into the sitemap list. Throws RuntimeException if no loc was staged. Chainable. -
generateXml(): string
Generate and return the sitemap XML string. Use this to return XML from controller routes. -
outputXml(): void
Send Content-Type: application/xml; charset=UTF-8 and echo the generated XML. Convenience helper for quick endpoints. saveToFile(string $filePath): void
Write the generated sitemap XML to the given file path.
Migration notes (from previous versions that had addBaseUrl()
)
If you upgraded from a version that supported addBaseUrl() and relative paths:
-
Before (old):
- Now (new):
Why: The library no longer maintains global base URL state. This makes the API explicit and safer for mixed-domain usages.
Best practices
-
Always call
save()
afteraddUrl()
(or use positional arguments withaddUrl(...)->save()
). -
Use
generateXml()
to return XML from controllers (so the framework can manage responses). -
Use
outputXml()
only for simple scripts or endpoints where you want the library to send headers. - For bulk imports, add entries in a loop and call
save()
per entry, or implement your own batching helper.
License
This project is licensed under the MIT
License.
Author
Krish Siddhapura — [email protected] — https://github.com/KRI55H
Keywords (for SEO)
PHP sitemap generator, XML sitemap, SEO sitemap PHP, SiteMapper, sitemap generator, Laravel sitemap generator, dynamic sitemap, Laravel dynamic sitemap generator.
All versions of php-sitemapper with dependencies
ext-json Version *