{"id":17093991,"url":"https://github.com/spatie/laravel-robots-middleware","last_synced_at":"2025-05-14T15:07:15.895Z","repository":{"id":44875620,"uuid":"49018008","full_name":"spatie/laravel-robots-middleware","owner":"spatie","description":"Enable or disable the indexing of your app","archived":false,"fork":false,"pushed_at":"2025-02-21T14:12:56.000Z","size":74,"stargazers_count":330,"open_issues_count":0,"forks_count":33,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-10T19:12:44.882Z","etag":null,"topics":["google","laravel","php","robots","seo"],"latest_commit_sha":null,"homepage":"https://freek.dev/350-say-goodbye-to-manually-creating-a-robotstxt-file","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/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"custom":"https://spatie.be/open-source/support-us"}},"created_at":"2016-01-04T19:24:34.000Z","updated_at":"2025-05-02T14:32:53.000Z","dependencies_parsed_at":"2024-06-18T12:32:08.244Z","dependency_job_id":"e22a7972-8e02-41e8-99eb-bc7eb9aae946","html_url":"https://github.com/spatie/laravel-robots-middleware","commit_stats":{"total_commits":66,"total_committers":11,"mean_commits":6.0,"dds":0.5757575757575757,"last_synced_commit":"78e00d56db4f238fa66973d93adfccfa58aec2fa"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-robots-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-robots-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-robots-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-robots-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-robots-middleware/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169545,"owners_count":22026212,"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":["google","laravel","php","robots","seo"],"created_at":"2024-10-14T14:09:55.463Z","updated_at":"2025-05-14T15:07:15.867Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://spatie.be/open-source/support-us"],"categories":[],"sub_categories":[],"readme":"# Enable or disable the indexing of your app\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-robots-middleware.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-robots-middleware)\n[![run-tests](https://github.com/spatie/laravel-robots-middleware/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-robots-middleware/actions/workflows/run-tests.yml)\n![Check \u0026 fix styling](https://github.com/spatie/laravel-robots-middleware/workflows/Check%20\u0026%20fix%20styling/badge.svg)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-robots-middleware.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-robots-middleware)\n\nA tiny, opinionated package to enable or disable indexing your site via a middleware in Laravel.\n\nMore on the Robots meta tag: https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag\n\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-robots-middleware.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-robots-middleware)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Installation\n\nYou can install the package via composer:\n``` bash\n$ composer require spatie/laravel-robots-middleware\n```\n\n## Usage\n\nBy default, the middleware enables indexing on all pages. You'll probably want to inherit your own class containing you application's indexing rule handler.  \n\n```php\n// app/Http/Middleware/MyRobotsMiddleware.php\nnamespace App\\Http\\Middleware;\n\nuse Illuminate\\Http\\Request;\nuse Spatie\\RobotsMiddleware\\RobotsMiddleware;\n\nclass MyRobotsMiddleware extends RobotsMiddleware\n{\n    /**\n     * @return string|bool\n     */\n    protected function shouldIndex(Request $request)\n    {\n        return $request-\u003esegment(1) !== 'admin';\n    }\n}\n```\n\nNext, simply register the newly created class in your middleware stack. \n\n```php\n// app/Http/Kernel.php\n\nclass Kernel extends HttpKernel\n{\n    protected $middleware = [\n        // ...\n        \\App\\Http\\Middleware\\MyRobotsMiddleware::class,\n    ];\n    \n    // ...\n}\n```\n\nThat's it! Responses will now always have an `x-robots-tag` in their headers, containing an `all` or `none` value.\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. Due to nature of this package, there's a fair chance features won't be accepted to keep it light and opinionated.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Credits\n\n- [Sebastian De Deyne](https://github.com/sebastiandedeyne)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-robots-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-robots-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-robots-middleware/lists"}