Middleware 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.
- PHP >= 5.6
- A PSR-7 http mesage implementation (Diactoros, Guzzle, Slim, etc...)
- A PSR-15 middleware dispatcher
This package is installable and autoloadable via Composer as middlewares/robots.
composer require middlewares/robots
$dispatcher = new Dispatcher([
new Middlewares\Robots(false)
]);
$response = $dispatcher->dispatch(new ServerRequest());
echo $response->getHeaderLine('X-Robots-Tag'); //noindex, nofollow, noarchive
Set true
to allow search engines and false
to disallow.
Optional url of a sitemap file.
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.