PHPackages                             oihana/php-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. [CLI &amp; Console](/categories/cli)
4. /
5. oihana/php-robots

ActiveLibrary[CLI &amp; Console](/categories/cli)

oihana/php-robots
=================

The Oihana PHP Robots library

1.0.0(9mo ago)010MPL-2.0PHPPHP &gt;=8.4

Since Aug 12Pushed 1mo agoCompare

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

READMEChangelogDependencies (10)Versions (2)Used By (0)

Oihana PHP - Robots
===================

[](#oihana-php---robots)

[![Oihana PHP Robots](https://raw.githubusercontent.com/BcommeBois/oihana-php-robots/main/assets/images/oihana-php-robots-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-robots/main/assets/images/oihana-php-robots-logo-inline-512x160.png)

A PHP library to create and manage `robots.txt` files, built on top of the oihana-php-commands library.

[![Latest Version](https://camo.githubusercontent.com/477ba0d38e0d4c98f625a1ad950d3f80e83a4b5a57f513e3d0dfe22a679a38eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d726f626f74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-robots)
[![Total Downloads](https://camo.githubusercontent.com/2dbe9d645bb9cc28d321f3ddec5e5c6eddc0a8ed8011cd3b3f0ceead0610e71f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d726f626f74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-robots)
[![License](https://camo.githubusercontent.com/cb02c0b92cb89cd88d6bc495c1deee55ae55b1c202d04b2e7ef799712379021b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d726f626f74732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

✨ Features
----------

[](#-features)

- Create or remove a project's robots.txt from the CLI
- Optional custom path via -f|--file (absolute or relative)
- Clear console support via -c|--clear
- Config-driven defaults (config.toml)

A robots.txt file is a simple text file placed on a website’s root directory to give instructions to web crawlers (like search engine bots) about which pages or sections of the site should or shouldn’t be crawled and indexed. It helps control search engine access and manage site visibility.

📦 Installation
--------------

[](#-installation)

> Requires PHP 8.4+

Install via Composer:

```
composer require oihana/php-robots
```

🚀 Usage
-------

[](#-usage)

The package provides a Symfony Console command named command:robots with actions:

- create: Generate a `robots.txt` file
- remove: Delete a `robots.txt` file

Examples:

Create a `robots.txt` using defaults

```
bin/console command:robots create
```

Create a `robots.txt` at a custom path

```
bin/console command:robots create --path /var/www/my-website/htdocs/robots.txt
```

or

```
bin/console command:robots create --p /var/www/my-website/htdocs/robots.txt
```

Remove the default `robots.txt`

```
bin/console command:robots remove
```

Remove a robots.txt at a custom path

```
bin/console command:robots remove --path /var/www/my-website/htdocs/robots.txt
```

Clear the console before running

```
bin/console command:robots create --clear
```

### Options

[](#options)

OptionShortCutDescription--clear-cClear the console before running--path-pThe directory path of the 'robots.txt' file**Notes:**

- If `--path` is a relative path, it is resolved against the current working directory.
- On creation/removal, parent directory existence and permissions are validated.

⚙️ Configuration
----------------

[](#️-configuration)

You can set defaults in config/config.toml under the \[robots\] section:

```
[robots]
path        = "/path/to/your/project/htdocs"
overwrite   = true
permissions = 0o644
owner       = "www-data"
group       = "www-data"
content     = '''
User-agent: *
Disallow: /
'''
```

🧪 Programmatic usage
--------------------

[](#-programmatic-usage)

You can instantiate and configure the command in PHP if needed:

```
use DI\Container;
use oihana\robots\commands\RobotsCommand;

$container = new Container();
$command = new RobotsCommand
(
    null,        // let kernel resolve the name
    $container,
    [
        'robots' => [
            'path'    => '/var/www/my-website/htdocs',
            'content' => "User-agent: *\nDisallow: /private/"
        ]
    ]
);
```

🔚 Exit codes
------------

[](#-exit-codes)

- 0 Success
- 1 Failure (invalid action, IO failure, etc.)

❓ Troubleshooting
-----------------

[](#-troubleshooting)

- Ensure the parent directory for the `robots.txt` is writable (especially when using a custom `--path` option).
- When using relative paths with `--path`, they are resolved from the current working directory (pwd).
- For more details, see the inline documentation in [RobotsCommand.php](https://github.com/BcommeBois/oihana-php-robots/blob/main/src/oihana/robots/commands/RobotsCommand.php).

✅ Running Unit Tests
--------------------

[](#-running-unit-tests)

To run all tests:

```
composer test
```

🧾 License
---------

[](#-license)

This project is licensed under the Mozilla Public License 2.0 (MPL-2.0).

👤 About the author
------------------

[](#-about-the-author)

- Author: Marc ALCARAZ (aka eKameleon)
- Mail:
- Website:

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance76

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

280d ago

### Community

Maintainers

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

---

Top Contributors

[![ekameleon](https://avatars.githubusercontent.com/u/749032?v=4)](https://github.com/ekameleon "ekameleon (17 commits)")

---

Tags

phpconsolecommandrobots.txt

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k239.8M286](/packages/nunomaduro-termwind)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2582.1M11](/packages/nunomaduro-laravel-console-task)[alecrabbit/php-cli-snake

Lightweight cli spinner with zero dependencies

29211.3k5](/packages/alecrabbit-php-cli-snake)

PHPackages © 2026

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