{"id":33974744,"url":"https://github.com/middlewares/robots","last_synced_at":"2025-12-13T01:50:56.903Z","repository":{"id":62528354,"uuid":"70071645","full_name":"middlewares/robots","owner":"middlewares","description":"PSR-15 middleware to enable/disable the robots of the search engines","archived":false,"fork":false,"pushed_at":"2025-03-26T14:44:07.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-26T06:21:01.920Z","etag":null,"topics":["http","middleware","psr-15","robots-txt","seo"],"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/middlewares.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-05T15:06:56.000Z","updated_at":"2025-03-23T10:25:17.000Z","dependencies_parsed_at":"2022-11-02T16:15:39.828Z","dependency_job_id":null,"html_url":"https://github.com/middlewares/robots","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/middlewares/robots","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Frobots","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Frobots/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Frobots/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Frobots/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/middlewares","download_url":"https://codeload.github.com/middlewares/robots/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/middlewares%2Frobots/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27697994,"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-12T02:00:06.775Z","response_time":129,"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":["http","middleware","psr-15","robots-txt","seo"],"created_at":"2025-12-13T01:50:56.396Z","updated_at":"2025-12-13T01:50:56.891Z","avatar_url":"https://github.com/middlewares.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# middlewares/robots\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE)\n![Testing][ico-ga]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nMiddleware to enable/disable the robots of the search engines for non-production environment. Adds automatically the header `X-Robots-Tag` in all responses and returns a default body for `/robots.txt` request.\n\n## Requirements\n\n* PHP \u003e= 7.2\n* A [PSR-7 http library](https://github.com/middlewares/awesome-psr15-middlewares#psr-7-implementations)\n* A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)\n\n## Installation\n\nThis package is installable and autoloadable via Composer as [middlewares/robots](https://packagist.org/packages/middlewares/robots).\n\n```sh\ncomposer require middlewares/robots\n```\n\n## Example\n\n```php\n$dispatcher = new Dispatcher([\n    new Middlewares\\Robots(false)\n]);\n\n$response = $dispatcher-\u003edispatch(new ServerRequest());\n\necho $response-\u003egetHeaderLine('X-Robots-Tag'); //noindex, nofollow, noarchive\n```\n\n## Usage\n\nThe constructor's first argument configure whether block or not search engines.\n\n```php\n//Disallow search engine robots\n$robots = new Middlewares\\Robots(false);\n\n//Allow search engine robots\n$robots = new Middlewares\\Robots(true);\n```\n\nOptionally, you can provide a `Psr\\Http\\Message\\ResponseFactoryInterface` as the second argument to create the response of the requests to `/robots.txt`. If it's not defined, [Middleware\\Utils\\Factory](https://github.com/middlewares/utils#factory) will be used to detect it automatically.\n\n```php\n$responseFactory = new MyOwnResponseFactory();\n\n$robots = new Middlewares\\Robots(false, $responseFactory);\n```\n\n### sitemap\n\nIf your site has a sitemap, use this option to add the url to `robots.txt` responses.\n\n```php\n$robots = (new Middlewares\\Robots(true))-\u003esitemap('/sitemap.xml');\n```\n---\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/middlewares/robots.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-ga]: https://github.com/middlewares/robots/workflows/testing/badge.svg\n[ico-downloads]: https://img.shields.io/packagist/dt/middlewares/robots.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/middlewares/robots\n[link-downloads]: https://packagist.org/packages/middlewares/robots\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Frobots","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiddlewares%2Frobots","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiddlewares%2Frobots/lists"}