{"id":13405127,"url":"https://github.com/samdark/sitemap","last_synced_at":"2025-05-15T08:00:23.021Z","repository":{"id":34348108,"uuid":"38269371","full_name":"samdark/sitemap","owner":"samdark","description":"Sitemap and sitemap index builder","archived":false,"fork":false,"pushed_at":"2023-11-01T08:43:27.000Z","size":115,"stargazers_count":534,"open_issues_count":13,"forks_count":88,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-05-14T10:59:55.046Z","etag":null,"topics":["hacktoberfest","php","sitemap"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samdark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"samdark","patreon":"samdark"}},"created_at":"2015-06-29T20:23:31.000Z","updated_at":"2025-05-01T09:29:31.000Z","dependencies_parsed_at":"2022-09-04T09:10:59.299Z","dependency_job_id":"634a4da7-c170-4b0a-8c7a-32ed0f65afa6","html_url":"https://github.com/samdark/sitemap","commit_stats":{"total_commits":57,"total_committers":18,"mean_commits":"3.1666666666666665","dds":0.5087719298245614,"last_synced_commit":"cf514750781275ad90fc9a828b4330c9c5ccba98"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdark%2Fsitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdark%2Fsitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdark%2Fsitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samdark%2Fsitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samdark","download_url":"https://codeload.github.com/samdark/sitemap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301420,"owners_count":22047901,"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","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":["hacktoberfest","php","sitemap"],"created_at":"2024-07-30T19:01:56.151Z","updated_at":"2025-05-15T08:00:22.772Z","avatar_url":"https://github.com/samdark.png","language":"PHP","funding_links":["https://github.com/sponsors/samdark","https://patreon.com/samdark"],"categories":["PHP","SEO"],"sub_categories":[],"readme":"Sitemap\n=======\n\nXML Sitemap and XML Sitemap Index builder.\n\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/samdark/sitemap?sort=semver\u0026style=flat-square)\n![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/samdark/sitemap/GitHub%20Action/master?label=tests\u0026style=flat-square)\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/samdark/sitemap?style=flat-square)\n![Packagist Downloads](https://img.shields.io/packagist/dm/samdark/sitemap?style=flat-square)\n![Packagist Downloads](https://img.shields.io/packagist/dt/samdark/sitemap?style=flat-square\u0026label=total%20downloads)\n![GitHub](https://img.shields.io/github/license/samdark/sitemap?style=flat-square)\n\nFeatures\n--------\n\n- Create sitemap files: either regular or gzipped.\n- Create multi-language sitemap files.\n- Create sitemap index files.\n- Use custom stylesheet.\n- Automatically creates new file if either URL limit or file size limit is reached.\n- Fast and memory efficient.\n\nInstallation\n------------\n\nInstallation via Composer is very simple:\n\n```\ncomposer require samdark/sitemap\n```\n\nAfter that, make sure your application autoloads Composer classes by including\n`vendor/autoload.php`.\n\nHow to use it\n-------------\n\n```php\nuse samdark\\sitemap\\Sitemap;\nuse samdark\\sitemap\\Index;\n\n// create sitemap\n$sitemap = new Sitemap(__DIR__ . '/sitemap.xml');\n\n// add some URLs\n$sitemap-\u003eaddItem('http://example.com/mylink1');\n$sitemap-\u003eaddItem('http://example.com/mylink2', time());\n$sitemap-\u003eaddItem('http://example.com/mylink3', time(), Sitemap::HOURLY);\n$sitemap-\u003eaddItem('http://example.com/mylink4', time(), Sitemap::DAILY, 0.3);\n\n// set sitemap stylesheet (see example-sitemap-stylesheet.xsl)\n$sitemap-\u003esetStylesheet('http://example.com/css/sitemap.xsl');\n\n// write it\n$sitemap-\u003ewrite();\n\n// get URLs of sitemaps written\n$sitemapFileUrls = $sitemap-\u003egetSitemapUrls('http://example.com/');\n\n// create sitemap for static files\n$staticSitemap = new Sitemap(__DIR__ . '/sitemap_static.xml');\n\n// add some URLs\n$staticSitemap-\u003eaddItem('http://example.com/about');\n$staticSitemap-\u003eaddItem('http://example.com/tos');\n$staticSitemap-\u003eaddItem('http://example.com/jobs');\n\n// set optional stylesheet (see example-sitemap-stylesheet.xsl)\n$staticSitemap-\u003esetStylesheet('http://example.com/css/sitemap.xsl');\n\n// write it\n$staticSitemap-\u003ewrite();\n\n// get URLs of sitemaps written\n$staticSitemapUrls = $staticSitemap-\u003egetSitemapUrls('http://example.com/');\n\n// create sitemap index file\n$index = new Index(__DIR__ . '/sitemap_index.xml');\n\n// set index stylesheet (see example in repo)\n$index-\u003esetStylesheet('http://example.com/css/sitemap.xsl');\n\n// add URLs\nforeach ($sitemapFileUrls as $sitemapUrl) {\n    $index-\u003eaddSitemap($sitemapUrl);\n}\n\n// add more URLs\nforeach ($staticSitemapUrls as $sitemapUrl) {\n    $index-\u003eaddSitemap($sitemapUrl);\n}\n\n// write it\n$index-\u003ewrite();\n```\n\nMulti-language sitemap\n----------------------\n\n```php\nuse samdark\\sitemap\\Sitemap;\n\n// create sitemap\n// be sure to pass `true` as second parameter to specify XHTML namespace\n$sitemap = new Sitemap(__DIR__ . '/sitemap_multi_language.xml', true);\n\n// Set URL limit to fit in default limit of 50000 (default limit / number of languages) \n$sitemap-\u003esetMaxUrls(25000);\n\n// add some URLs\n$sitemap-\u003eaddItem('http://example.com/mylink1');\n\n$sitemap-\u003eaddItem([\n    'ru' =\u003e 'http://example.com/ru/mylink2',\n    'en' =\u003e 'http://example.com/en/mylink2',\n], time());\n\n$sitemap-\u003eaddItem([\n    'ru' =\u003e 'http://example.com/ru/mylink3',\n    'en' =\u003e 'http://example.com/en/mylink3',\n], time(), Sitemap::HOURLY);\n\n$sitemap-\u003eaddItem([\n    'ru' =\u003e 'http://example.com/ru/mylink4',\n    'en' =\u003e 'http://example.com/en/mylink4',\n], time(), Sitemap::DAILY, 0.3);\n\n// set stylesheet (see example-sitemap-stylesheet.xsl)\n$sitemap-\u003esetStylesheet('http://example.com/css/sitemap.xsl');\n\n// write it\n$sitemap-\u003ewrite();\n\n```\n\nOptions\n-------\n\nThere are methods to configure `Sitemap` instance:\n \n- `setMaxUrls($number)`. Sets maximum number of URLs to write in a single file.\n  Default is 50000 which is the limit according to specification and most of\n  existing implementations.\n- `setMaxBytes($number)`. Sets maximum size of a single site map file.\n  Default is 10MiB which should be compatible with most current search engines.\n- `setBufferSize($number)`. Sets number of URLs to be kept in memory before writing it to file.\n  Default is 10. Bigger values give marginal benefits.\n  On the other hand when the file size limit is hit, the complete buffer must be written to the next file.\n- `setUseIndent($bool)`. Sets if XML should be indented. Default is true.\n- `setUseGzip($bool)`. Sets whether the resulting sitemap files will be gzipped or not.\n  Default is `false`. `zlib` extension must be enabled to use this feature.\n- `setStylesheet($string)`. Sets the `xml-stylesheet` tag. By default, tag is not generated. See example [example-sitemap-stylesheet.xsl](/example-sitemap-stylesheet.xsl)  \n\nThere is a method to configure `Index` instance:\n\n- `setUseGzip($bool)`. Sets whether the resulting index file will be gzipped or not.\n  Default is `false`. `zlib` extension must be enabled to use this feature.\n- `setStylesheet($string)`. Sets the `xml-stylesheet` tag. By default, tag is not generated. See example [example-sitemap-stylesheet.xsl](/example-sitemap-stylesheet.xsl) \n\nRunning tests\n-------------\n\nIn order to run tests perform the following commands:\n\n```\ncomposer install\n./vendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamdark%2Fsitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamdark%2Fsitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamdark%2Fsitemap/lists"}