Download the PHP package league/stack-robots without Composer
On this page you can find all versions of the php package league/stack-robots. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download league/stack-robots
More information about league/stack-robots
Files in league/stack-robots
Package stack-robots
Short Description StackRobots Middleware for StackPHP
License MIT
Informations about the package stack-robots
League\StackRobots
StackRobots is a middleware for StackPHP. It provides a default robots.txt for non-production environments.
Install Via Composer
Usage
StackRobots is a very simple middleware. By default it looks at the SERVER_ENV
environment variable,
and if the SERVER_ENV
does not equal production, it captures the response and sets an X-Robots-Tag
header with a value of noindex, nofollow, noarchive
.
When you push the middleware on to the stack, you can pass 2 additional parameters, $env
and $envVar
.
The $env
parameter is the environment in which you want this middleware to not do anything, typically
production
. The $envVar
parameter is the environment variable that holds the environment of the
current server; it defaults to SERVER_ENV
.
If the value of SERVER_ENV
matches the value that is passed, this middleware will just pass control on
to the next middleware. However, if it does not match, then StackRobots will set the X-Robots-Tag
.
Additionally, if the incoming request is for your /robots.txt
file, then StackRobots will stop the request
and send the following response.
And this is what the browser receives.
More info on the
X-Robots-Tag
is available here.
Example
Authors
- Don Gilbert @dilbert4life
- Inspired by Cylon for Ruby.