PHPackages                             gverschuur/laravel-robotstxt - 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. gverschuur/laravel-robotstxt

Abandoned → [verschuur/laravel-robotstxt](/?search=verschuur%2Flaravel-robotstxt)Library[Utility &amp; Helpers](/categories/utility)

gverschuur/laravel-robotstxt
============================

Set the robots.txt content dynamically based on the Laravel app environment.

5.2.0(1y ago)395214[1 issues](https://github.com/verschuur/laravel-robotstxt/issues)MITPHPPHP ^8.0

Since Oct 5Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/verschuur/laravel-robotstxt)[ Packagist](https://packagist.org/packages/gverschuur/laravel-robotstxt)[ RSS](/packages/gverschuur-laravel-robotstxt/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (4)Versions (16)Used By (0)

[![Run tests](https://github.com/verschuur/laravel-robotstxt/workflows/Run%20tests/badge.svg?branch=master)](https://github.com/verschuur/laravel-robotstxt/workflows/Run%20tests/badge.svg?branch=master) [![Code Climate issues](https://camo.githubusercontent.com/b8a6709de977569f709e2bf999c1e61b3cb360d4887601da036b3cd9af74330b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6973737565732f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/b8a6709de977569f709e2bf999c1e61b3cb360d4887601da036b3cd9af74330b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6973737565732f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265) [![Code Climate maintainability](https://camo.githubusercontent.com/25e789691140e1a1dca591fabf11e735fc4e1691a1ed3b7acd195e8153bd5085/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/25e789691140e1a1dca591fabf11e735fc4e1691a1ed3b7acd195e8153bd5085/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265) [![Scrutinizer](https://camo.githubusercontent.com/22afc19148acd9de0bd4391789ed2c207235d232785106b7c798ab6c4c4da7ec/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/22afc19148acd9de0bd4391789ed2c207235d232785106b7c798ab6c4c4da7ec/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7665727363687575722f6c61726176656c2d726f626f74737478742e7376673f7374796c653d666c61742d737175617265)

Dynamic robots.txt ServiceProvider for Laravel 🤖
================================================

[](#dynamic-robotstxt-serviceprovider-for-laravel-)

- [Installation](#installation)
    - [Composer](#composer)
    - [Manual](#manual)
    - [Service provider registration](#service-provider-registration)
- [Usage](#usage)
    - [Basic usage](#basic-usage)
    - [Custom settings](#custom-settings)
    - [Examples](#examples)
        - [Allow directive](#allow-directive)
    - [Sitemaps](#sitemaps)
        - [The standard production configuration](#the-standard-production-configuration)
        - [Adding multiple sitemaps](#adding-multiple-sitemaps)
- [Compatiblility](#compatiblility)
- [Testing](#testing)
- [robots.txt reference](#robotstxt-reference)

Installation
============

[](#installation)

Composer
--------

[](#composer)

```
composer require verschuur/laravel-robotstxt
```

Manual
------

[](#manual)

Add the following to your `composer.json` and then run `composer install`.

```
{
    "require": {
        "verschuur/laravel-robotstxt": "^3.0"
    }
}
```

Service provider registration
-----------------------------

[](#service-provider-registration)

This package supports Laravel's service provider autodiscovery so that's it. If you wish to register the package manually, add the ServiceProvider to the providers array in `config/app.php`.

```
Verschuur\Laravel\RobotsTxt\Providers\RobotsTxtProvider::class
```

Usage
=====

[](#usage)

Basic usage
-----------

[](#basic-usage)

This package adds a `/robots.txt` route to your application. Remember to remove the physical `robots.txt` file from your `/public` dir or else it will take precedence over Laravel's route and this package will not work.

By default, the `production` environment will show

```
User-agent: *
Disallow:
```

while every other environment will show

```
User-agent: *
Disallow: /
```

This will allow the default install to allow all robots on a production environment, while disallowing robots on every other environment.

Custom settings
---------------

[](#custom-settings)

If you need custom sitemap entries, publish the configuration file

```
php artisan vendor:publish --provider="Verschuur\Laravel\RobotsTxt\Providers\RobotsTxtProvider"
```

This will copy the `robots-txt.php` config file to your app's `config` folder. In this file you will find the following array structure

```
'environments' => [
    '{environment name}' => [
        'paths' => [
            '{robot name}' => [
                'disallow' => [
                    ''
                ],
                'allow' => []
            ],
        ]
    ]
]
```

In which:

- `{environment name}`: the enviroment for which to define the paths.
- `{robot name}`: the robot for which to define the paths.
- `disallow`: all entries which will be used by the `disallow` directive.
- `allow`: all entries which will be used by the `allow` directive.

By default, the environment name is set to `production` with a robot name of `*` and a disallow entry consisting of an empty string. This will allow all bots to access all paths on the production environment.

**Note:** If you do not define any environments in this configuration file (i.e. an empty configuration), the default will always be to disallow all bots for all paths.

Examples
--------

[](#examples)

For brevity, the `environment` array key will be disregarded in these examples.

Allow all paths for all robots on production, and disallow all paths for every robot in staging.

```
'production' => [
    'paths' => [
        '*' => [
            'disallow' => [
                ''
            ]
        ]
    ]
],
'staging' => [
    'paths' => [
        '*' => [
            'disallow' => [
                '/'
            ]
        ]
    ]
]
```

Allow all paths for all robot *bender* on production, but disallow `/admin` and `/images` on production for robot *flexo*

```
'production' => [
    'paths' => [
        'bender' => [
            'disallow' => [
                ''
            ]
        ],
        'flexo' => [
            'disallow' => [
                '/admin',
                '/images'
            ]
        ]
    ]
],
```

### Allow directive

[](#allow-directive)

Besides the more standard `disallow` directive, the `allow` directive is also supported.

Allow a path, but disallow sub paths:

```
'production' => [
    'paths' => [
        '*' => [
            'disallow' => [
                '/foo/bar'
            ],
            'allow' => [
                '/foo'
            ]
        ]
    ]
],
```

When the file is rendered, the `disallow` directives will always be placed before the `allow` directives.

If you don't need one or the other directive, and you wish to keep the configuration file clean, you can simply remove the entire key from the entire array.

Sitemaps
--------

[](#sitemaps)

This package also allows to add sitemaps to the robots file. By default, the production environment will add a sitemap.xml entry to the file. You can remove this default entry from the `sitemaps` array if you don't need it.

Because sitemaps always need to an absolute url, they are automatically wrapped using [Laravel's url() helper function](https://laravel.com/docs/7.x/helpers#method-url). The sitemap entries in the config file should be relative to the webroot.

### The standard production configuration

[](#the-standard-production-configuration)

```
'environments' => [
    'production' => [
        'sitemaps' => [
            'sitemap.xml'
        ]
    ]
]
```

### Adding multiple sitemaps

[](#adding-multiple-sitemaps)

```
'environments' => [
    'production' => [
        'sitemaps' => [
            'sitemap-articles.xml',
            'sitemap-products.xml',
            'sitemap-etcetera.xml'
        ]
    ]
]
```

Compatiblility
==============

[](#compatiblility)

This package is compatible with Laravel 9, 10, 11 and 12. For a complete overview of supported Laravel and PHP versions, please refer to the ['Run test' workflow](https://github.com/verschuur/laravel-robotstxt/actions).

Testing
=======

[](#testing)

PHPUnit test cases are provided in `/tests`. Run the tests through `composer run test` or `vendor/bin/phpunit --configuration phpunit.xml`.

robots.txt reference
====================

[](#robotstxt-reference)

The following reference was while creating this package:

[https://developers.google.com/search/reference/robots\_txt](https://developers.google.com/search/reference/robots_txt)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance65

Regular maintenance activity

Popularity22

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 91.1% 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 ~278 days

Recently: every ~178 days

Total

12

Last Release

486d ago

Major Versions

v1.1.1 → v2.0.02020-01-02

v2.0.0 → 3.02020-03-05

3.1.0 → 4.0.02022-04-05

4.0.0 → 5.02023-03-13

PHP version history (2 changes)4.0.0PHP ^7.3|^8.0

5.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a54082f960b74e066939ab1b1fde8a63a31c55cfb1581f39d20ede748cb9e4c3?d=identicon)[verschuur](/maintainers/verschuur)

---

Top Contributors

[![verschuur](https://avatars.githubusercontent.com/u/1265398?v=4)](https://github.com/verschuur "verschuur (92 commits)")[![IT-Joris](https://avatars.githubusercontent.com/u/122261387?v=4)](https://github.com/IT-Joris "IT-Joris (4 commits)")[![annejan](https://avatars.githubusercontent.com/u/294470?v=4)](https://github.com/annejan "annejan (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![Quezler](https://avatars.githubusercontent.com/u/3179271?v=4)](https://github.com/Quezler "Quezler (1 commits)")

---

Tags

phplaravelrobots.txt

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gverschuur-laravel-robotstxt/health.svg)

```
[![Health](https://phpackages.com/badges/gverschuur-laravel-robotstxt/health.svg)](https://phpackages.com/packages/gverschuur-laravel-robotstxt)
```

###  Alternatives

[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341790.3k28](/packages/gehrisandro-tailwind-merge-laravel)[verschuur/laravel-robotstxt

Set the robots.txt content dynamically based on the Laravel app environment.

39421.7k1](/packages/verschuur-laravel-robotstxt)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17818.7k](/packages/markwalet-nova-modal-response)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2518.6k](/packages/iteks-laravel-enum)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1319.7k3](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.2k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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