PHPackages                             seophp/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. seophp/robots

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

seophp/robots
=============

Lightweight, framework-agnostic robots.txt management for PHP

02PHPCI passing

Since Mar 1Pushed 2mo agoCompare

[ Source](https://github.com/seo-php/robots)[ Packagist](https://packagist.org/packages/seophp/robots)[ RSS](/packages/seophp-robots/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Robots
======

[](#robots)

[![Total Downloads](https://camo.githubusercontent.com/a3c0052864305102212d02048f0b8a3460bb2991c7bf50a40df3347b09d60028/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73656f7068702f726f626f7473)](https://packagist.org/packages/seophp/robots)[![Latest Stable Version](https://camo.githubusercontent.com/87c5a40643ba78965848fe0c37ebe1d001cbfbf1b2133f0773e72f3165c0f41a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656f7068702f726f626f7473)](https://packagist.org/packages/seophp/robots)[![License](https://camo.githubusercontent.com/52556758058a9a8dca88fb87b9d9977410dfc790e8720991136dc197a8de34ee/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73656f7068702f726f626f7473)](https://packagist.org/packages/seophp/robots)[![PHP Minimum Version](https://camo.githubusercontent.com/9aa64716fde031dce14de7e41b3de4ede7cdefaadde38d45264e11b103abc184/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e342b2d3737374242343f6c6f676f3d706870)](https://php.net)

Lightweight, framework-agnostic `robots.txt` management for PHP.

Requirements
------------

[](#requirements)

- PHP 8.4 or higher

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

[](#installation)

Install via [Composer](https://getcomposer.org):

```
composer require seophp/robots
```

Usage
-----

[](#usage)

You may create an instance of the main `RobotsTxt` class by hand:

```
use Seo\Robots\RobotsTxt;
use Seo\Robots\RobotsTxtGroup;
use Seo\Robots\RobotsTxtDirective;

$robots = new RobotsTxt(
    groups: [
        new RobotsTxtGroup(
            agents: ['*'],
            directives: [
                new RobotsTxtDirective('Disallow', '/admin'),
            ],
        ),
    ],
    sitemaps: [
        'https://example.com/sitemap.xml',
    ],
);
```

### Using the builder

[](#using-the-builder)

You may use the `RobotsTxtBuilder` to construct a `RobotsTxt` instance with a fluent API:

```
use Seo\Robots\RobotsTxtBuilder;
use Seo\Robots\RobotsTxtGroupBuilder;

$robots = (new RobotsTxtBuilder())
    ->group(fn (RobotsTxtGroupBuilder $g) => $g
        ->agent('*')
        ->disallow('/admin')
        ->allow('/admin/public')
        ->crawlDelay(10)
    )
    ->group(fn (RobotsTxtGroupBuilder $g) => $g
        ->agent('Googlebot')
        ->agent('Bingbot')
        ->disallow('/')
    )
    ->sitemap('https://example.com/sitemap.xml')
    ->build();
```

### Rendering

[](#rendering)

You may use the `RobotsTxtRenderer` to convert a `RobotsTxt` instance to a string:

```
use Seo\Robots\RobotsTxtRenderer;

$renderer = new RobotsTxtRenderer();

$output = $renderer->render($robots);
```

Output:

```
User-agent: *
Disallow: /admin
Allow: /admin/public
Crawl-delay: 10

User-agent: Googlebot
User-agent: Bingbot
Disallow: /

Sitemap: https://example.com/sitemap.xml

```

### Parsing

[](#parsing)

You may use the `RobotsTxtParser` to parse a robots.txt string into a `RobotsTxt` instance:

```
use Seo\Robots\RobotsTxtParser;

$parser = new RobotsTxtParser();

$robots = $parser->parse($content);
```

Note

- Uses blank lines as group separators
- Preserves original directive casing
- Strips comments (`#` and everything after)
- Throws `RobotsTxtParseException` on malformed lines or directives without a preceding `User-agent`

### Querying

[](#querying)

The `RobotsTxt` instance provides methods to check crawling permissions following [RFC 9309](https://www.rfc-editor.org/rfc/rfc9309) semantics:

```
$robots->isAllowed('Googlebot', '/public');    // true
$robots->isDisallowed('Googlebot', '/admin');  // true
$robots->crawlDelayFor('Googlebot');           // int or null
```

#### Matching rules

[](#matching-rules)

- **Agent resolution**: case-insensitive prefix matching. `"Googlebot-News"` matches a `"Googlebot"` group. The most specific (longest) matching agent wins, with `*` as fallback.
- **Path matching**: longest matching directive wins. Supports `*` (wildcard) and `$` (end anchor) in patterns.
- **Conflict resolution**: when `Allow` and `Disallow` patterns have equal length, `Allow` wins.
- **Default**: paths are allowed when no directive matches.

License
-------

[](#license)

The MIT License (MIT). See the [license file](LICENSE) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance56

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ce7b6c97be6045063ccacafcc49a200b1066d5dfd5a125aec669687c1b8effb?d=identicon)[dllobell](/maintainers/dllobell)

---

Top Contributors

[![dllobell](https://avatars.githubusercontent.com/u/49846756?v=4)](https://github.com/dllobell "dllobell (1 commits)")

### Embed Badge

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

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

###  Alternatives

[igbinary/igbinary

Igbinary is a drop in replacement for the standard php serializer. Instead of the time and space consuming textual representation used by PHP's serialize(), igbinary stores php data structures in a compact binary form. Savings are significant when using memcached or similar memory based storages for serialized data.

7801.7k](/packages/igbinary-igbinary)[droptica/droopler

Droopler - SEO Friendly CMS &amp; Site Builder - is a Drupal-based website builder that helps you create beautiful, fast, and easy-to-manage websites

6543.1k1](/packages/droptica-droopler)[sinergi/token

PHP library to generate random strings

188.7k9](/packages/sinergi-token)[andychukse/laravel-pricing-plans

A package provide pricing plans for Laravel.

121.8k](/packages/andychukse-laravel-pricing-plans)

PHPackages © 2026

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