PHPackages                             league/stack-robots - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. league/stack-robots

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

league/stack-robots
===================

StackRobots Middleware for StackPHP

v1.1.1(12y ago)684.8k5MITPHPPHP &gt;=5.3.10

Since Nov 2Pushed 12y ago4 watchersCompare

[ Source](https://github.com/thephpleague/stack-robots)[ Packagist](https://packagist.org/packages/league/stack-robots)[ RSS](/packages/league-stack-robots/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

League\\StackRobots
===================

[](#leaguestackrobots)

[![Build Status](https://camo.githubusercontent.com/9d53fec8aa9ba9b728adda103c463fe7bf44c7756c91021c21279113726b8a95/68747470733a2f2f7472617669732d63692e6f72672f7068702d6c6f65702f537461636b526f626f74732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/php-loep/StackRobots)[![Total Downloads](https://camo.githubusercontent.com/2398451f9649f01a8bc2a022e30be6e8fd25115f2aadd6b4c701cbfa6a8aa3c3/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f737461636b2d726f626f74732f646f776e6c6f6164732e706e67)](https://packagist.org/packages/league/stack-robots)[![Latest Stable Version](https://camo.githubusercontent.com/894d3333a5262b788a5607e4ee9f99352e7a1501bb174f07b9905fbbed53c976/68747470733a2f2f706f7365722e707567782e6f72672f6c65616775652f737461636b2d726f626f74732f762f737461626c652e706e67)](https://packagist.org/packages/league/stack-robots)

StackRobots is a middleware for [StackPHP](http://stackphp.com). It provides a default robots.txt for non-production environments.

Install Via Composer
--------------------

[](#install-via-composer)

```
{
    "require": {
        "league/stack-robots": "~1.0"
    }
}
```

Usage
-----

[](#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.

```
return new Response("User-Agent: *\nDisallow: /", 200, array('Content-Type' => 'text/plain'));
```

And this is what the browser receives.

```
User-Agent: *
Disallow: /
```

> More info on the `X-Robots-Tag` is available [here](https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag).

Example
-------

[](#example)

```
include_once '../vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use League\StackRobots\Robots;

$app = new Stack\CallableHttpKernel(function (Request $request) {
    return new Response('Hello World!');
});

putenv('SERVER_ENV=dev');

$app = (new Stack\Builder)
    ->push('League\\StackRobots\\Robots')
    ->resolve($app);

Stack\run($app);
```

Authors
-------

[](#authors)

- Don Gilbert [@dilbert4life](http://twitter.com/dilbert4life)
- Inspired by [Cylon](https://github.com/dmathieu/cylon) for Ruby.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~46 days

Total

3

Last Release

4532d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/67381?v=4)[Phil Sturgeon](/maintainers/philsturgeon)[@philsturgeon](https://github.com/philsturgeon)

![](https://www.gravatar.com/avatar/3a5327d87a2a2d37a9412d5706442399763d86cb773f81adbe58c8d749393e2d?d=identicon)[alexbilbie](/maintainers/alexbilbie)

![](https://avatars.githubusercontent.com/u/718028?v=4)[Don Gilbert](/maintainers/dongilbert)[@dongilbert](https://github.com/dongilbert)

---

Top Contributors

[![dongilbert](https://avatars.githubusercontent.com/u/718028?v=4)](https://github.com/dongilbert "dongilbert (11 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")

### Embed Badge

![Health badge](/badges/league-stack-robots/health.svg)

```
[![Health](https://phpackages.com/badges/league-stack-robots/health.svg)](https://phpackages.com/packages/league-stack-robots)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k181.3M2.2k](/packages/symfony-security-bundle)[symfony/security-http

Symfony Security Component - HTTP Integration

1.7k172.8M350](/packages/symfony-security-http)[symfony/ux-autocomplete

JavaScript Autocomplete functionality for Symfony

635.5M36](/packages/symfony-ux-autocomplete)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
