{"id":15068508,"url":"https://github.com/charcoalphp/contrib-sitemap","last_synced_at":"2026-01-29T07:39:38.623Z","repository":{"id":107032196,"uuid":"506023854","full_name":"charcoalphp/contrib-sitemap","owner":"charcoalphp","description":"CONTRIB — Sitemap builder for Charcoal","archived":false,"fork":false,"pushed_at":"2024-06-07T15:51:09.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-02T04:05:09.994Z","etag":null,"topics":["contribution","php","sitemap-generator"],"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/charcoalphp.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-21T22:35:30.000Z","updated_at":"2024-06-07T15:50:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"e97f54da-620a-4304-b635-24b3d420e6d2","html_url":"https://github.com/charcoalphp/contrib-sitemap","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/charcoalphp/contrib-sitemap","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fcontrib-sitemap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fcontrib-sitemap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fcontrib-sitemap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fcontrib-sitemap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charcoalphp","download_url":"https://codeload.github.com/charcoalphp/contrib-sitemap/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charcoalphp%2Fcontrib-sitemap/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28870639,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T07:35:32.468Z","status":"ssl_error","status_checked_at":"2026-01-29T07:33:31.463Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["contribution","php","sitemap-generator"],"created_at":"2024-09-25T01:37:53.904Z","updated_at":"2026-01-29T07:39:38.609Z","avatar_url":"https://github.com/charcoalphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Charcoal Sitemap\n================\n\n[![License][badge-license]](LICENSE)\n[![Build Status][badge-github]][github-actions]\n[![Latest Release][badge-release]][github-latest]\n[![Supported PHP Version][badge-php]](composer.json)\n\nA [Charcoal][charcoal/charcoal] package for generating a sitemap.\n\n## Installation\n\n```shell\ncomposer require charcoal/contrib-sitemap\n```\n\n### Setup\n\nFor Charcoal projects, the package can be registered in two ways.\n\n#### Charcoal Module\n\nThe Sitemap's module will register the service provider (see below) and\nthe route (`/sitemap.xml`).\n\nThe module can be registered from your configuration file:\n\n```json\n\"modules\": {\n    \"charcoal/sitemap/sitemap\": {}\n}\n```\n\n#### Charcoal Service Provider\n\nThe Sitemap's service provider will register the necessary services (see below)\nfor building a sitemap.\n\nThe service provider can be registered from your configuration file:\n\n```json\n{\n    \"service_providers\": {\n        \"charcoal/view/service-provider/view\": {}\n    }\n}\n```\n\nTo register a route from your configuration file:\n\n```json\n{\n    \"routes\": {\n        \"actions\": {\n            \"sitemap.xml\": {\n                \"route\": \"/sitemap.xml\",\n                \"methods\": [ \"GET\" ],\n                \"controller\": \"charcoal/sitemap/action/sitemap\",\n                \"action_data\": {\n                    \"sitemap_ident\": \"xml\"\n                }\n            }\n        }\n    }\n}\n```\n\nBy default, the action controller will look for a sitemap hierarchy named `xml`\nwhich can be changed via the `sitemap_ident` controller setting.\n\n## Overview\n\n### Routes\n\n* **`GET /sitemap.xml`** — A route assigned to `Charcoal\\Sitemap\\Action\\SitemapAction`.  \n  Used to serve the XML document.\n\n### Services\n\n* **`charcoal/sitemap/builder`** — Instance of `Charcoal\\Sitemap\\Service\\Builder`.  \n  Used to generate the collections of links from the configured models.\n* **`sitemap/formatter/xml`** — Instance of `Charcoal\\Sitemap\\Service\\XmlFormatter`.  \n  Used to generate the XML from one or more collections of links from the `Builder`.\n* **`sitemap/presenter`** — Instance of `Charcoal\\Sitemap\\Service\\SitemapPresenter`.  \n  Used to resolve model transformations.\n* **`sitemap/transformer/factory`** — Instance of `Charcoal\\Factory\\GenericFactory`\n  ([charcoal/factory]).  \n  Used to resolve object transformers from object types.\n\n## Configuration\n\nThe Sitemap can be configured from the application configset under the\n`sitemap` key. You can setup which objects to be included and available\ntranslations (l10n).\n\nMost options are renderable by objects using your application's chosen\ntemplate syntax (Mustache used in examples below).\n\n### Default Options\n\n```jsonc\n{\n    /**\n     * The service's configuration point.\n     */\n    \"sitemap\": {\n        /**\n         * One or more groups to customize how objects should be processed.\n         *\n         * The array key is an arbitrary identifier for the grouping of models.\n         */\n        \"\u003cgroup-name\u003e\": {\n            /**\n             * Whether or not to include links to translations.\n             *\n             * - `true` — Multilingual. Include all translations\n             *   (see `locales.languages`).\n             * - `false` — Unilingual. Include only the default language\n             *   (see `locales.default_language`).\n             */\n            \"l10n\": false,\n            /**\n             * The language to include a link to if group is unilingual.\n             *\n             * If `l10n` is `true`, this option is ignored.\n             *\n             * Defaults to the application's current language.\n             */\n            \"locale\": \"\u003ccurrent-language\u003e\",\n            /**\n             * Whether or not to check if the routable object\n             * has an active route (`RoutableInterface#isActiveRoute()`)\n             *\n             * - `true` — Include only routable objects with active routes.\n             * - `false` — Ignore if a routable object's route is active.\n             */\n            \"check_active_routes\": false,\n            /**\n             * Whether or not to prepend relative URIs with\n             * the application's base URI (see `base_url`).\n             *\n             * - `true` — Use only the object's URI (see `sitemap.*.objects.*.url`).\n             * - `false` — Prepend the base URI if object's URI is relative.\n             */\n            \"relative_urls\": false,\n            /**\n             * The transformer to parse each model included in `objects`.\n             *\n             * Either a PHP FQCN or snake-case equivalent.\n             */\n            \"transformer\": \"\u003cclass-string\u003e\",\n            /**\n             * Map of models to include in the sitemap.\n             */\n            \"objects\": {\n                /**\n                 * One or more models to customize and include in the sitemap.\n                 *\n                 * The array key must be the model's object type,\n                 * like `app/model/foo-bar`, or fully-qualified name (FQN),\n                 * like `App\\Model\\FooBar`.\n                 */\n                \"\u003cobject-type\u003e\": {\n                    /**\n                     * The transformer to parse the object.\n                     *\n                     * Either a PHP FQCN or snake-case equivalent.\n                     */\n                    \"transformer\": \"\u003cclass-string\u003e\",\n                    /**\n                     * The URI of the object for the `\u003cloc\u003e` element.\n                     */\n                    \"url\": \"{{ url }}\",\n                    /**\n                     * The name of the object. Can be used in a\n                     * custom sitemap builder or XML generator.\n                     */\n                    \"label\": \"{{ title }}\",\n                    /**\n                     * Map of arbitrary object data that can be used\n                     * in a custom sitemap builder or XML generator.\n                     */\n                    \"data\": {},\n                    /**\n                     * List or map of collection filters of which objects\n                     * to include in the sitemap.\n                     *\n                     * ```json\n                     * \"\u003cfilter-name\u003e\": {\n                     *     \"property\": \"active\",\n                     *     \"value\": true\n                     * }\n                     * ```\n                     */\n                    \"filters\": [],\n                    /**\n                     * List or map of collection orders to sort the objects\n                     * in the sitemap.\n                     *\n                     * ```json\n                     * \"\u003corder-name\u003e\": {\n                     *     \"property\": \"position\",\n                     *     \"direction\": \"ASC\"\n                     * }\n                     * ```\n                     */\n                    \"orders\": [],\n                    /**\n                     * Map of models to include in the sitemap\n                     * below this model.\n                     *\n                     * Practical to group related models.\n                     */\n                    \"children\": {\n                        /**\n                         * One or more models to customize and include in the sitemap.\n                         */\n                        \"\u003cobject-type\u003e\": {\n                            /**\n                             * A constraint on the parent object to determine\n                             * if the child model's objects should be included\n                             * in the sitemap.\n                             */\n                            \"condition\": null\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\nEach model can override the following options of their group:\n`l10n`, `locale`, `check_active_routes`, `relative_urls`.\n\n\n### Example\n\nThe example below, identified as `footer_sitemap`, is marked as multilingual\nusing the `l10n` option which will include all translations.\n\n```json\n{\n    \"sitemap\": {\n        \"footer_sitemap\": {\n            \"l10n\": true,\n            \"check_active_routes\": true,\n            \"relative_urls\": false,\n            \"transformer\": \"charcoal/sitemap/transformer/routable\",\n            \"objects\": {\n                \"app/object/section\": {\n                    \"transformer\": \"\\\\App\\\\Transformer\\\\Sitemap\\\\Section\",\n                    \"label\": \"{{ title }}\",\n                    \"url\": \"{{ url }}\",\n                    \"filters\": {\n                        \"active\": {\n                            \"property\": \"active\",\n                            \"value\": true\n                        }\n                    },\n                    \"data\": {\n                        \"id\": \"{{ id }}\",\n                        \"metaTitle\": \"{{ metaTitle }}\"\n                    },\n                    \"children\": {\n                        \"app/object/section-children\": {\n                            \"condition\": \"{{ isAnObjectParent }}\"\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n```\n\n## Usage\n\n### Using the builder\n\nThe builder returns only an array. You need to make your own converter\nif you need another format.\n\nGiven the settings above:\n\n```php\n$builder = $container['charcoal/sitemap/builder'];\n// 'footer_sitemap' is the ident of the settings you want.\n$links = $builder-\u003ebuild('footer_sitemap');\n```\n\nYou can also use the `SitemapBuilderAwareTrait`, which includes the setter and\ngetter for the sitemap builder, in order to use it with minimal code in every\nnecessary class.\n\n### XML Formatter\n\nThe XML formatter generates a valid XML sitemap from the array returned\nby the builder.\n\n```php\n$builder = $container['charcoal/sitemap/builder'];\n$links   = $builder-\u003ebuild('footer_sitemap');\n\n$formatter = $container['sitemap/formatter/xml'];\n$sitemap   = $formatter-\u003ecreateXmlFromCollections($links);\n```\n\n## Development\n\nTo install the development environment:\n\n```shell\ncomposer install\n```\n\nTo run the scripts (PHP lint, PHPCS, PHPStan, and PHPUnit):\n\n```shell\ncomposer lint\ncomposer test\n```\n\n## License\n\nCharcoal is licensed under the MIT license. See [LICENSE](LICENSE) for details.\n\n[charcoal/charcoal]: https://github.com/charcoalphp/charcoal\n[charcoal/factory]:  https://github.com/charcoalphp/factory\n\n[badge-github]:      https://img.shields.io/github/actions/workflow/status/charcoalphp/contrib-sitemap/ci.yml?branch=main\n[badge-license]:     https://poser.pugx.org/charcoal/contrib-sitemap/license\n[badge-php]:         https://img.shields.io/packagist/php-v/charcoal/charcoal?style=flat-square\u0026logo=php\n[badge-release]:     https://img.shields.io/github/tag/charcoalphp/contrib-sitemap.svg\n\n[github-actions]:    https://github.com/charcoalphp/contrib-sitemap/actions\n[github-latest]:     https://github.com/charcoalphp/contrib-sitemap/releases/latest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharcoalphp%2Fcontrib-sitemap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharcoalphp%2Fcontrib-sitemap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharcoalphp%2Fcontrib-sitemap/lists"}