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

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

becklyn/robots-txt
==================

A library to build robots.txt

1.1.0(4y ago)29.2k↑11.1%BSD-3-ClausePHPPHP &gt;=7.4

Since Nov 13Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Becklyn/robots-txt)[ Packagist](https://packagist.org/packages/becklyn/robots-txt)[ Docs](https://github.com/Becklyn/robots-txt)[ RSS](/packages/becklyn-robots-txt/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Robots.txt Library
==================

[](#robotstxt-library)

Usage
-----

[](#usage)

First, you need to create a builder. With this builder you can create sections for different user agents and add the directives to it.

You can also add a header to the robots.txt and register your sitemap URLs.

### Adding Sections

[](#adding-sections)

```
use Becklyn\RobotsTxt\Builder\RobotsTxtBuilder;

$builder = new RobotsTxtBuilder();

// adding a section
$builder->getSection("google")
    ->allow("/public")
    ->disallow("/admin")
    ->crawlDelay(20);

$builder->getSection("bing")
    ->allow("/public")
    ->disallow("/admin")
    ->disallow("/private")
    ->crawlDelay(15);
```

If multiple search engines have the same directives, you can add one section for all of them:

```
$builder->getSection("google", "bing")
    ->allow("/public")
    ->disallow("/admin")
    ->crawlDelay(20);
```

The builder tries to bundle combine the directives of multiple sections if possible:

```
$builder->getSection("google")
    ->allow("/public");

// ... some code ...

$builder->getSection("google")
    ->disallow("/admin")

// will produce a single entry:
//
//      User-Agent: google
//      Allow: /public
//      Disallow: /admin
```

### Sitemaps

[](#sitemaps)

```
$builder
    ->addSitemap("https://example.org/sitemap.xml.tar.gz")
    ->addSitemap("https://example.org/sitemap.xml");
```

### Header

[](#header)

You can also add a header which will be included at the very top:

```
$builder
    ->setHeader("This is some example text");

$builder->getSection("google")
    ->allow("/public");

// Will produce:
//
//      # This is some example text
//
//      User-Agent: google
//      Allow: /public
```

### Outputting the robots.txt

[](#outputting-the-robotstxt)

```
$content = $builder->getFormatted();
file_put_contents("robots.txt", $content);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~238 days

Recently: every ~298 days

Total

6

Last Release

1550d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.1.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1044355?v=4)[Becklyn Studios](/maintainers/becklyn)[@Becklyn](https://github.com/Becklyn)

---

Top Contributors

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

---

Tags

libraryphprobots-txt

### Embed Badge

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

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

PHPackages © 2026

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