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

ActiveLibrary

tourze/robots-txt-bundle
========================

robots.txt管理

0.1.0(4mo ago)00MITPHPCI passing

Since Jun 1Pushed 4mo agoCompare

[ Source](https://github.com/tourze/robots-txt-bundle)[ Packagist](https://packagist.org/packages/tourze/robots-txt-bundle)[ RSS](/packages/tourze-robots-txt-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (30)Versions (3)Used By (0)

RobotsTxt Bundle
================

[](#robotstxt-bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/c21aacd462ef3babe487609e6b0a6de90cbb1355741c749c1a90b7cab893a545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f726f626f74732d7478742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/robots-txt-bundle)[![PHP Version](https://camo.githubusercontent.com/86e1efa8bc3c6eb45a664688e9593ffbebfd142d244b697625c3b7ccce99b2eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f726f626f74732d7478742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/robots-txt-bundle)[![Total Downloads](https://camo.githubusercontent.com/fe43af3cce03ccd61f26ecc0e5b979c1746f6cc8a2c1028234ddbe2e056b187f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f726f626f74732d7478742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/robots-txt-bundle)[![License](https://camo.githubusercontent.com/23b7e8f37b690683727706fb1791d8fa1c6bd34602b41095e967c3e7612f3c3e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f726f626f74732d7478742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/488ff9954bf11ccd9733ed2c7cb6ae7365655f711c4ec3d081189885028b8b7b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f726f626f74732d7478742d62756e646c652f63692e796d6c3f7374796c653d666c61742d737175617265)](https://github.com/tourze/robots-txt-bundle/actions)[![Code Coverage](https://camo.githubusercontent.com/d0c05278edb20f4f0e7917dd00919befd46fb36fd8bec32e946860e6f3b95971/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f726f626f74732d7478742d62756e646c653f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/robots-txt-bundle)

A Symfony Bundle for managing `robots.txt` files with a multi-provider architecture, allowing flexible assembly and generation of robots.txt content.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Requirements](#requirements)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Basic Usage](#basic-usage)
    - [Creating Custom Providers](#creating-custom-providers)
- [API Reference](#api-reference)
    - [RobotsTxtDirective](#robotstxtdirective)
    - [RobotsTxtRule](#robotstxtrule)
    - [RobotsTxtEntry](#robotstxtentry)
- [Advanced Usage](#advanced-usage)
    - [Dynamic Rules](#dynamic-rules)
    - [Conditional Providers](#conditional-providers)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- 🤖 **Complete robots.txt support**: Support for all standard directives (User-agent, Allow, Disallow, Crawl-delay, Sitemap, etc.)
- 🔌 **Multi-provider architecture**: Collect rules from multiple sources by implementing `RobotsTxtProviderInterface`
- 🎯 **Priority control**: Support provider priority to flexibly control rule merging order
- 🌍 **Environment support**: Provide different robots.txt content based on different environments
- ⚡ **Performance optimization**: Built-in caching strategy to reduce server load
- 📖 **Standards compliant**: Follows [Google robots.txt specification](https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt)
- 🔧 **Auto-configuration**: Providers are automatically registered using Symfony's autoconfiguration

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

[](#installation)

```
composer require tourze/robots-txt-bundle
```

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

[](#requirements)

- PHP 8.1 or higher
- Symfony 6.4 or higher

Configuration
-------------

[](#configuration)

The Bundle works out of the box with minimal configuration. The `/robots.txt`route is automatically registered and will collect content from all registered providers.

### Custom Configuration

[](#custom-configuration)

If you need to customize the Bundle behavior, create a configuration file:

```
# config/packages/robots_txt.yaml
robots_txt:
    cache_enabled: true
    cache_ttl: 3600
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

The Bundle automatically registers a `/robots.txt` route that returns the generated robots.txt content.

### Creating Custom Providers

[](#creating-custom-providers)

```
