PHPackages                             spatie/laravel-robots-middleware - 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. spatie/laravel-robots-middleware

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

spatie/laravel-robots-middleware
================================

Add an `all` or `none` robots header to your requests via a middleware in Laravel

1.4.2(2mo ago)3352.1M↑13.9%335MITPHPPHP ^8.2CI passing

Since Jan 5Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/spatie/laravel-robots-middleware)[ Packagist](https://packagist.org/packages/spatie/laravel-robots-middleware)[ Docs](https://github.com/spatie/laravel-robots-middleware)[ Fund](https://spatie.be/open-source/support-us)[ RSS](/packages/spatie-laravel-robots-middleware/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (14)Used By (5)

Enable or disable the indexing of your app
==========================================

[](#enable-or-disable-the-indexing-of-your-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/54fb5f328509f71111cfd592244348a9c6def37fb3ca41ded5a6c7513dc87d85/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d726f626f74732d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-robots-middleware)[![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)[![Check & fix styling](https://github.com/spatie/laravel-robots-middleware/workflows/Check%20&%20fix%20styling/badge.svg)](https://github.com/spatie/laravel-robots-middleware/workflows/Check%20&%20fix%20styling/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/4b2f576a6d823db349341f8235998cd563792f21ed45297f08b9c4055b6bc8cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d726f626f74732d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-robots-middleware)

A tiny, opinionated package to enable or disable indexing your site via a middleware in Laravel.

More on the Robots meta tag: [https://developers.google.com/webmasters/control-crawl-index/docs/robots\_meta\_tag](https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag)

Spatie 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).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/4ab8cae7a68634c4de5a0d01e62a32bf56bfc69b592633e9b527b789576edb90/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d726f626f74732d6d6964646c65776172652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-robots-middleware)

We 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).

We 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).

Installation
------------

[](#installation)

You can install the package via composer:

```
$ composer require spatie/laravel-robots-middleware
```

Usage
-----

[](#usage)

By default, the middleware enables indexing on all pages. You'll probably want to inherit your own class containing you application's indexing rule handler.

```
// app/Http/Middleware/MyRobotsMiddleware.php
namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Spatie\RobotsMiddleware\RobotsMiddleware;

class MyRobotsMiddleware extends RobotsMiddleware
{
    /**
     * @return string|bool
     */
    protected function shouldIndex(Request $request)
    {
        return $request->segment(1) !== 'admin';
    }
}
```

Next, simply register the newly created class in your middleware stack.

```
// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \App\Http\Middleware\MyRobotsMiddleware::class,
    ];

    // ...
}
```

That's it! Responses will now always have an `x-robots-tag` in their headers, containing an `all` or `none` value.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please 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.

Security
--------

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

68

—

FairBetter than 100% of packages

Maintenance83

Actively maintained with recent releases

Popularity61

Solid adoption and visibility

Community29

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50.6% 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 ~336 days

Recently: every ~373 days

Total

12

Last Release

86d ago

PHP version history (4 changes)1.0.0PHP ^7.0

1.1.0PHP ^7.2

1.3.0PHP ^7.2|^8.0

1.4.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (39 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (7 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (3 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (2 commits)")[![akoepcke](https://avatars.githubusercontent.com/u/5311185?v=4)](https://github.com/akoepcke "akoepcke (2 commits)")[![manojLondhe](https://avatars.githubusercontent.com/u/1375006?v=4)](https://github.com/manojLondhe "manojLondhe (1 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (1 commits)")

---

Tags

googlelaravelphprobotsseospatieindexseorobots

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/spatie-laravel-robots-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-robots-middleware/health.svg)](https://phpackages.com/packages/spatie-laravel-robots-middleware)
```

###  Alternatives

[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[spatie/laravel-feed

Generate rss feeds

9743.6M28](/packages/spatie-laravel-feed)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-googletagmanager

Google Tag Manager integration for Laravel

4413.4M5](/packages/spatie-laravel-googletagmanager)[spatie/laravel-referer

Keep a visitor's original referer in session

532797.4k6](/packages/spatie-laravel-referer)

PHPackages © 2026

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