Download the PHP package moneo/markdown-for-agents without Composer
On this page you can find all versions of the php package moneo/markdown-for-agents. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download moneo/markdown-for-agents
More information about moneo/markdown-for-agents
Files in moneo/markdown-for-agents
Package markdown-for-agents
Short Description Laravel package for Cloudflare's Markdown conversion services.
License MIT
Informations about the package markdown-for-agents
Laravel Markdown for Agents
A Laravel package that unifies Cloudflare's three Markdown conversion services under one elegant API.
Services
| Service | Driver Key | Description |
|---|---|---|
| Markdown for Agents | agents |
Content negotiation via Accept: text/markdown on any Cloudflare-enabled URL. Free, no auth. |
| Workers AI toMarkdown | workers_ai |
Converts files (PDF, DOCX, images, etc.) to Markdown via REST API. Auth required. |
| Browser Rendering | browser |
Headless browser renders JS-heavy pages then converts to Markdown. Auth required. |
Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
Installation
Publish the config file:
Configuration
Add your Cloudflare credentials to .env:
The agents driver does not require credentials.
Usage
Convert a URL
Convert a file
Convert raw HTML
Choose a driver
Fallback
If the primary driver fails, automatically retry with another:
Browser options
Cache control
Caching is enabled by default for URL and HTML conversions:
Conditional fluent API
PendingConversion uses Laravel's Conditionable and Tappable traits:
Supported formats
Driver Comparison
| Scenario | Recommended Driver |
|---|---|
| Cloudflare-enabled site | agents (fastest, free) |
| PDF, DOCX, XLSX, images | workers_ai (only option) |
| SPA / JS-heavy page | browser (full render) |
| Non-Cloudflare site | browser |
| Raw HTML string | browser |
| Make your app agent-ready | Middleware (local, no API) |
Middleware
Add the middleware to routes to make your Laravel app respond with Markdown when AI agents request it:
When a request includes Accept: text/markdown, the middleware converts HTML responses to Markdown locally using league/html-to-markdown. No Cloudflare API calls are made.
Response headers added:
Content-Type: text/markdown; charset=utf-8Vary: acceptx-markdown-tokens: {count}Content-Signal: ai-train=yes, search=yes, ai-input=yes
Artisan Commands
Events
Two events are dispatched during conversions:
MarkdownConverted— on success (includes result, source, duration)ConversionFailed— on failure (includes source, driver, exception)
Custom Drivers
Register custom drivers that implement MarkdownConverterInterface:
Testing
The package uses orchestra/testbench. All tests mock HTTP responses -- no real API calls.
When testing your own app's code that uses this package, mock the facade:
License
MIT
All versions of markdown-for-agents with dependencies
illuminate/contracts Version ^11.0|^12.0
illuminate/support Version ^11.0|^12.0
illuminate/http Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.0
league/html-to-markdown Version ^5.0