{"id":24578235,"url":"https://github.com/kri55h/php-sitemapper","last_synced_at":"2026-02-07T04:31:59.129Z","repository":{"id":273730184,"uuid":"920646054","full_name":"KRI55H/php-sitemapper","owner":"KRI55H","description":"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. Designed for modern PHP projects and frameworks (Laravel, Codeigniter, Symfony, plain PHP). ","archived":false,"fork":false,"pushed_at":"2025-08-09T14:13:08.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-16T20:18:26.339Z","etag":null,"topics":["dynamic-sitemap","laravel-sitemap","php","sitemap-generator","xml"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KRI55H.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-22T14:26:19.000Z","updated_at":"2025-10-08T10:11:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"06835ca8-814c-4570-801d-2bf8da521364","html_url":"https://github.com/KRI55H/php-sitemapper","commit_stats":null,"previous_names":["kri55h/php-sitemapper"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/KRI55H/php-sitemapper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KRI55H%2Fphp-sitemapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KRI55H%2Fphp-sitemapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KRI55H%2Fphp-sitemapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KRI55H%2Fphp-sitemapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KRI55H","download_url":"https://codeload.github.com/KRI55H/php-sitemapper/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KRI55H%2Fphp-sitemapper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29186736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T03:35:06.566Z","status":"ssl_error","status_checked_at":"2026-02-07T03:34:57.604Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-sitemap","laravel-sitemap","php","sitemap-generator","xml"],"created_at":"2025-01-23T23:58:20.957Z","updated_at":"2026-02-07T04:31:59.123Z","avatar_url":"https://github.com/KRI55H.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SiteMapper\n\n**SiteMapper** is a lightweight, chainable PHP library to generate SEO-friendly XML sitemaps dynamically.  \nDesigned for modern PHP projects and frameworks (Laravel, Codeigniter, Symfony, plain PHP). \n\n---\n\n## Features\n\n- Fluent API: `addUrl(...)-\u003esave()` for concise, readable code.  \n- Add per-URL metadata: `priority`, `lastmod` and `changefreq`.  \n- `generateXml()` returns an XML string ready to return from controllers.  \n- `outputXml()` sends correct headers and echoes XML directly.  \n- `saveToFile()` writes sitemap XML to disk.  \n- Minimal dependencies — requires only PHP and SimpleXML.\n\n---\n\n## Requirements\n\n- PHP **7.4** or newer  \n- `ext-simplexml` enabled\n\n---\n\n## Installation\n\nInstall via Composer:\n\n```bash\ncomposer require kri55h/php-sitemapper\n```\nThen autoload:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse Kri55h\\SiteMapper;\n```\n\n## Quick Example (recommended)\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse Kri55h\\SiteMapper;\n\n$map = new SiteMapper();\n\n// Add and save entries (pass full URLs)\n$map-\u003eaddUrl('https://example.com/about', 0.8, '2025-08-09', 'daily')-\u003esave()\n    -\u003eaddUrl('https://example.com/contact', 0.5, '2025-08-09', 'weekly')-\u003esave();\n\n// Return XML from a controller or script\nheader('Content-Type: application/xml; charset=UTF-8');\necho $map-\u003egenerateXml();\n```\n**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()``.\n\n## Full Example (all functions / backwards-compatible style)\n```php\n\u003c?php\nrequire 'vendor/autoload.php';\n\nuse Kri55h\\SiteMapper;\n\n$map = new SiteMapper();\n\n// Staged style: call setters, then save()\n$map-\u003eaddUrl('https://example.com/')\n    -\u003esetPriority(1.0)\n    -\u003esetLastModified('2025-08-09')\n    -\u003esetChangeFrequency('daily')\n    -\u003esave();\n\n// Another entry, using positional args\n$map-\u003eaddUrl('https://example.com/about', 0.8, '2025-08-09', 'weekly')-\u003esave();\n\n// Save sitemap to disk\n$map-\u003esaveToFile(__DIR__ . '/public/sitemap.xml');\n\n// Or output directly (sets header + echoes XML)\n$map-\u003eoutputXml();\n```\n## Public API Reference\n- ``addUrl(string $location, ?float $priority = null, ?string $last_modified = null, ?string $change_frequency = null): self``\nAdds a staged URL entry. Pass a full URL (https://example.com/page). Returns $this for chaining.\n\n- ``setPriority(float $priority): self``\nSet priority (0.0 — 1.0) for the currently staged entry. Chainable.\n\n- ``setLastModified(string $last_modified): self``\nSet the last modified date (YYYY-MM-DD) for the currently staged entry. Chainable.\n\n- ``setChangeFrequency(string $change_frequency): self``\nSet change frequency (always|hourly|daily|weekly|monthly|yearly|never). Chainable.\n\n- ``save(): self``\nCommit the currently staged entry into the sitemap list. Throws RuntimeException if no loc was staged. Chainable.\n\n- ``generateXml(): string``\nGenerate and return the sitemap XML string. Use this to return XML from controller routes.\n\n- ``outputXml(): void``\nSend Content-Type: application/xml; charset=UTF-8 and echo the generated XML. Convenience helper for quick endpoints.\n\n- ``saveToFile(string $filePath): void``\nWrite the generated sitemap XML to the given file path.\n\n## Migration notes (from previous versions that had ``addBaseUrl()``)\nIf you upgraded from a version that supported addBaseUrl() and relative paths:\n- **Before (old):**\n```php\n$map-\u003eaddBaseUrl('https://example.com');\n$map-\u003eaddUrl('/about');\necho $map-\u003egenerateXml();\n```\n- **Now (new):**\n```php\n$map-\u003eaddUrl('https://example.com/about')-\u003esave();\necho $map-\u003egenerateXml();\n```\n**Why**: The library no longer maintains global base URL state. This makes the API explicit and safer for mixed-domain usages.\n\n## Best practices\n- Always call ``save()`` after ``addUrl()`` (or use positional arguments with ``addUrl(...)-\u003esave()``).\n\n- Use ``generateXml()`` to return XML from controllers (so the framework can manage responses).\n\n- Use ``outputXml()`` only for simple scripts or endpoints where you want the library to send headers.\n\n- For bulk imports, add entries in a loop and call ``save()`` per entry, or implement your own batching helper.\n\n## License\nThis project is licensed under the ``MIT`` License.\n\n\n##  Author\n\nKrish Siddhapura — siddhapurakrish007@gmail.com — https://github.com/KRI55H\n\n## Keywords (for SEO)\n\nPHP sitemap generator, XML sitemap, SEO sitemap PHP, SiteMapper, sitemap generator, Laravel sitemap generator, dynamic sitemap, Laravel dynamic sitemap generator.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkri55h%2Fphp-sitemapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkri55h%2Fphp-sitemapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkri55h%2Fphp-sitemapper/lists"}