{"id":33018387,"url":"https://github.com/tackk/cartographer","last_synced_at":"2025-12-17T16:50:07.615Z","repository":{"id":16288084,"uuid":"19036633","full_name":"tackk/cartographer","owner":"tackk","description":"A PHP sitemap generation tool.","archived":false,"fork":false,"pushed_at":"2023-11-22T11:51:28.000Z","size":474,"stargazers_count":327,"open_issues_count":7,"forks_count":38,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-11-16T14:03:16.801Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://tackk.github.io/cartographer/","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/tackk.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2014-04-22T16:17:44.000Z","updated_at":"2025-03-15T20:59:02.000Z","dependencies_parsed_at":"2024-01-12T10:25:59.632Z","dependency_job_id":"a431c3f4-b69d-41da-b773-94888229d1da","html_url":"https://github.com/tackk/cartographer","commit_stats":{"total_commits":60,"total_committers":4,"mean_commits":15.0,"dds":0.06666666666666665,"last_synced_commit":"9f938498f98c620148370c1b69b84f9044de98b0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/tackk/cartographer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tackk%2Fcartographer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tackk%2Fcartographer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tackk%2Fcartographer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tackk%2Fcartographer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tackk","download_url":"https://codeload.github.com/tackk/cartographer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tackk%2Fcartographer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27784811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-17T02:00:08.291Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-11-13T18:00:39.567Z","updated_at":"2025-12-17T16:50:07.564Z","avatar_url":"https://github.com/tackk.png","language":"PHP","funding_links":[],"categories":["导航","Navigation","导航( Navigation )","Files","导航 Navigation"],"sub_categories":[],"readme":"# Cartographer\n\n[![Latest Stable Version](https://poser.pugx.org/tackk/cartographer/version.png)](https://packagist.org/packages/tackk/cartographer)\n[![Total Downloads](https://poser.pugx.org/tackk/cartographer/d/total.png)](https://packagist.org/packages/tackk/cartographer)\n[![License](https://poser.pugx.org/tackk/cartographer/license.png)](https://packagist.org/packages/tackk/cartographer)\n\n[![Build Status](https://travis-ci.org/tackk/cartographer.svg)](https://travis-ci.org/tackk/cartographer)\n[![Code Coverage](https://scrutinizer-ci.com/g/tackk/cartographer/badges/coverage.png?s=5547a47fb7e014a26cc4b43f69832f82b673d8ba)](https://scrutinizer-ci.com/g/tackk/cartographer/)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/tackk/cartographer/badges/quality-score.png?s=47b9d98507fa3ea5be94ef3656a3de5a5bff662d)](https://scrutinizer-ci.com/g/tackk/cartographer/)\n\nA sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html).\n\nCartographer can handle Sitemaps of any size.  When generating sitemaps with more than 50,000\nentries (the limit), the sitemap becomes a \"map of maps\" (i.e. nested sitemaps).\n\n* **GitHub Repo:** [http://github.com/tackk/cartographer/](http://github.com/tackk/cartographer/)\n* **Documentation:** [http://tackk.github.io/cartographer/](http://tackk.github.io/cartographer/)\n\n## Supported PHP/HHVM Versions\n\n* **PHP:** \u003e= 5.4 (including 5.6 beta1)\n* **HHVM:** \u003e= 3.0.0\n\n## Installation\n\n### Composer CLI\n\n```\ncomposer require tackk/cartographer:1.0.*\n```\n\n### composer.json\n\n``` json\n{\n    \"require\": {\n        \"tackk/cartographer\": \"1.0.*\"\n    }\n}\n```\n\n## Basic Sitemap\n\nIf you have a sitemap that is under 50,000 items, you can just use the Sitemap class, and avoid the Sitemap\nGenerator.\n\n``` php\nuse Tackk\\Cartographer\\Sitemap;\nuse Tackk\\Cartographer\\ChangeFrequency;\n\n$sitemap = new Tackk\\Cartographer\\Sitemap();\n$sitemap-\u003eadd('http://foo.com', '2005-01-02', ChangeFrequency::WEEKLY, 1.0);\n$sitemap-\u003eadd('http://foo.com/about', '2005-01-01');\n\n// Write it to a file\nfile_put_contents('sitemap.xml', (string) $sitemap);\n\n// or simply echo it:\nheader ('Content-Type:text/xml');\necho $sitemap-\u003etoString();\n```\n\n### Output\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003curlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\u003e\n  \u003curl\u003e\n    \u003cloc\u003ehttp://foo.com\u003c/loc\u003e\n    \u003clastmod\u003e2005-01-02T00:00:00+00:00\u003c/lastmod\u003e\n    \u003cchangefreq\u003eweekly\u003c/changefreq\u003e\n    \u003cpriority\u003e1\u003c/priority\u003e\n  \u003c/url\u003e\n  \u003curl\u003e\n    \u003cloc\u003ehttp://foo.com/about\u003c/loc\u003e\n    \u003clastmod\u003e2005-01-01T00:00:00+00:00\u003c/lastmod\u003e\n  \u003c/url\u003e\n\u003c/urlset\u003e\n```\n\n## Basic Sitemap Index\n\nIf you want to build a Sitemap Index, separate from the Sitemap Generator, you can!\n\n``` php\n$sitemapIndex = new Tackk\\Cartographer\\SitemapIndex();\n$sitemapIndex-\u003eadd('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');\n$sitemapIndex-\u003eadd('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');\n\n// Write it to a file\nfile_put_contents('sitemap.xml', (string) $sitemapIndex);\n\n// or simply echo it:\nheader ('Content-Type:text/xml');\necho $sitemapIndex-\u003etoString();\n```\n\n### Output\n\n``` xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003csitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\u003e\n  \u003curl\u003e\n    \u003cloc\u003ehttp://foo.com/sitemaps/sitemap.1.xml\u003c/loc\u003e\n    \u003clastmod\u003e2012-01-02T00:00:00+00:00\u003c/lastmod\u003e\n  \u003c/url\u003e\n  \u003curl\u003e\n    \u003cloc\u003ehttp://foo.com/sitemaps/sitemap.2.xml\u003c/loc\u003e\n    \u003clastmod\u003e2012-01-02T00:00:00+00:00\u003c/lastmod\u003e\n  \u003c/url\u003e\n\u003c/sitemapindex\u003e\n```\n\n## Sitemap Factory\n\nThe Sitemap Factory create Sitemaps and Sitemap Indexes and writes them to the Filesystem.\nIs is can be used to generate full Sitemaps with more than **50,000** URLs.\n\nIf more than one sitemap is generated, it will create a Sitemap Index automatically.\n\n### Instantiating\n\nThe factory uses [Flysystem](http://flysystem.thephpleague.com/) to write the sitemaps.  This\nmeans you can write the sitemaps to Local Disk, S3, Dropbox, wherever you want.\n\n``` php\n\u003c?php\n\nuse League\\Flysystem\\Filesystem;\nuse League\\Flysystem\\Adapter\\Local as LocalAdapter;\n\n$adapter = new LocalAdapter(__DIR__.'/sitemaps');\n$filesystem = new Filesystem($adapter);\n$sitemapFactory = new Tackk\\Cartographer\\SitemapFactory($filesystem);\n\n```\n\n### Base URL\n\nThe Base URL is used when generating the Sitemap Indexes, and for the returned entry point URL.\n\nYou can set the Base URL:\n\n``` php\n$sitemapFactory-\u003esetBaseUrl('http://foo.com/sitemaps/');\n```\n\nYou can get the current base URL using `getBaseUrl()`.\n\n### Creating a Sitemap\n\nTo create a sitemap you use the `createSitemap` method.  This method requires an `Iterator` as\nits only parameter.\n\n``` php\n\u003c?php\n\nuse League\\Flysystem\\Filesystem;\nuse League\\Flysystem\\Adapter\\Local as LocalAdapter;\n\n$adapter = new LocalAdapter(__DIR__.'/sitemaps');\n$filesystem = new Filesystem($adapter);\n$sitemapFactory = new Tackk\\Cartographer\\SitemapFactory($filesystem);\n\n// Create an Iterator of your URLs somehow.\n$urls = get_url_iterator();\n\n// Returns the URL to the main Sitemap/Index file\n$mainSitemap = $sitemapFactory-\u003ecreateSitemap($urls);\n\n```\n\n### Return Value\n\nThe two creation methods (`createSitemap` and `createSitemapIndex`) will return the URL\nof the root sitemap file.  If there is only 1 sitemap created, it will return just that URL.\nIf multiple sitemaps are created, then a Sitemap Index is generated and the URL to that is returned.\n\n### List of Created Files\n\nYou can get a list (array) of files the Factory has created by using the `getFilesCreated` method.\n\n``` php\n$files = $sitemapFactory-\u003egetFilesCreated();\n```\n\n## Running Tests\n\n*This assumes you have ran `composer update`.*\n\nFrom the repository root, run:\n\n```\nvendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftackk%2Fcartographer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftackk%2Fcartographer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftackk%2Fcartographer/lists"}