Download the PHP package soleinjast/symfony-markdown-response-bundle without Composer
On this page you can find all versions of the php package soleinjast/symfony-markdown-response-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package symfony-markdown-response-bundle

Introduction
A Symfony bundle that automatically serves Markdown versions of your HTML pages to AI agents, bots, and any client that requests it. Controllers opt in with a single PHP attribute — the bundle handles detection, conversion, and caching transparently.
Why
AI assistants (ChatGPT, Claude, Perplexity, etc.) and autonomous agents consume web content better as plain Markdown than as HTML. Stripping navigation, scripts, styles, and markup noise reduces token usage and improves comprehension — without maintaining a separate content pipeline.
Installation
If you are not using Symfony Flex, register the bundle manually:
Quick Start
1. Opt a controller in
Apply the #[ProvideMarkdownResponse] attribute to a controller class or to individual action methods.
Or enable it per-method and disable it on specific actions:
2. That's it
The bundle detects AI clients automatically. No changes to routes, templates, or responses are required.
How Detection Works
A request is considered to want Markdown if any of the following is true:
| Signal | Example |
|---|---|
Accept: text/markdown header |
Accept: text/markdown, */* |
.md URL suffix |
GET /docs/setup.md |
| Known AI User-Agent substring | User-Agent: GPTBot/1.0 |
_wants_markdown request attribute |
Set internally after .md rewrite |
The .md suffix is stripped before routing so your route definitions remain unchanged. The _wants_markdown attribute is set on the request to carry the intent forward to the response phase.
Default User-Agent patterns:
Configuration
Publish the configuration file (optional — all keys have defaults):
Configuration reference
| Key | Type | Default | Description |
|---|---|---|---|
driver |
local\|cloudflare |
local |
Conversion backend |
cloudflare_endpoint |
string\|null |
null |
Cloudflare Workers AI URL (required for cloudflare driver) |
cache_enabled |
bool |
true |
Cache converted Markdown |
cache_ttl |
int |
3600 |
Cache TTL in seconds |
cache_service |
string\|null |
null |
PSR-6 cache pool service ID; falls back to cache.app then cache.system |
ai_user_agents |
string[] |
(see above) | User-Agent substrings that trigger Markdown responses |
Conversion Drivers
local (default)
Uses league/html-to-markdown. Conversion happens in-process with no external dependencies. The following HTML nodes are stripped before conversion: head, script, style, nav, footer, aside.
cloudflare
Posts the HTML to a Cloudflare Workers AI endpoint and returns the response body as Markdown. Requires symfony/http-client and a configured endpoint URL.
Caching
Converted Markdown is cached by default using a PSR-6 cache pool. The cache key is derived from an xxh3 hash of the pre-processed HTML, so distinct page content produces distinct cache entries.
Resolution order for the cache pool:
cache_serviceif explicitly configuredcache.appif present in the containercache.systemif present in the container- No caching (conversion runs on every request)
To disable caching entirely:
Preprocessing Pipeline
You can strip or transform HTML before conversion by implementing HtmlPreprocessorInterface. Services implementing this interface are auto-configured via the symfony_markdown_response.html_preprocessor tag.
Register it as a service (or rely on autowiring/autoconfiguration):
Multiple preprocessors are applied in the order they are resolved from the container.
Accessing Markdown Programmatically
The MarkdownConverter service is available for injection if you need to convert HTML outside of the HTTP cycle:
Requesting Markdown as a Client
There are three ways to request a Markdown response:
1. URL suffix
2. Accept header
3. Known AI User-Agent (automatic — no client changes required)
All three methods produce a response with Content-Type: text/markdown; charset=UTF-8.
Contributing
Contributions are welcome. Please open an issue before submitting a pull request for significant changes so the approach can be discussed first.
- Fork the repository
- Create a feature branch:
git checkout -b feat/my-feature - Write tests for your changes
- Submit a pull request
License
Released under the MIT License.
Happy coding! 🎉
All versions of symfony-markdown-response-bundle with dependencies
symfony/http-kernel Version ^6.4|^7.0|^8.0
symfony/dependency-injection Version ^6.4|^7.0|^8.0
symfony/config Version ^6.4|^7.0|^8.0
league/html-to-markdown Version ^5.1