Download the PHP package shanginn/cloudflare-browser without Composer
On this page you can find all versions of the php package shanginn/cloudflare-browser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shanginn/cloudflare-browser
More information about shanginn/cloudflare-browser
Files in shanginn/cloudflare-browser
Package cloudflare-browser
Short Description A strongly-typed, modern PHP SDK for the Cloudflare Browser Rendering REST API
License MIT
Informations about the package cloudflare-browser
Cloudflare Browser Rendering PHP SDK
A strongly-typed, modern PHP SDK for the Cloudflare Browser Rendering REST API. Built with amphp/http-client for performance and crell/serde for robust object serialization.
Features
- Full Coverage: Supports
/content,/screenshot,/pdf,/scrape,/json,/snapshot,/links, and/markdownendpoints. - Strong Typing: Uses Request DTOs and specific Response objects.
- AI Extraction: Seamless integration with
spiral/json-schema-generatorto extract structured data from webpages into PHP objects. - Custom Exceptions: Granular error handling for API errors.
Installation
Documentation
📚 View the full Wiki Documentation for detailed guides on all endpoints.
Quick Links
- Getting Started & REST API Overview
- Fetching HTML Content
- Capturing Screenshots
- Generating PDFs
- Taking Snapshots
- Scraping Elements
- AI Structured Data Extraction
- Retrieving Links
- Extracting Markdown
Basic Usage
Setup
Take a Screenshot
See the Screenshot Documentation for more examples including:
- Custom HTML screenshots
- Authenticated pages
- Full-page captures
- Element-specific screenshots
- High-resolution captures
Scrape Elements
See the Scraping Documentation for more details.
Advanced Usage
AI Structured Data Extraction
Define your target data structure using a PHP class and attributes. The SDK will generate the JSON schema and map the AI response back to your object.
1. Define Schema:
2. Extract:
See the JSON Endpoint Documentation for more examples including array extraction and custom AI models.
Generating PDFs
See the PDF Documentation for more examples including:
- Custom headers and footers
- Page format options (A4, A5, Letter, etc.)
- Blocking images/resources
- Dynamic placeholders (page numbers, dates, titles)
Fetch HTML Content
See the Content Documentation for handling JavaScript-heavy pages and blocking resources.
Extract Markdown
See the Markdown Documentation for more details.
Get All Links
See the Links Documentation for more details.
Take a Snapshot
See the Snapshot Documentation for more examples.
Authentication
Before you begin, make sure you create a custom API Token with the following permissions:
Browser Rendering - Edit
Set these environment variables:
CLOUDFLARE_ACCOUNT_ID- Your Cloudflare Account IDCLOUDFLARE_API_TOKEN- Your Cloudflare API Token
Monitoring Usage
You can monitor Browser Rendering usage in two ways:
- In the Cloudflare dashboard, go to the Browser Rendering page to view aggregate metrics. Go to Browser Rendering
X-Browser-Ms-Usedheader: Returned in every REST API response, reporting browser time used for that request (in milliseconds).
Troubleshooting
If you have questions or encounter an error, see the Browser Rendering FAQ and troubleshooting guide.
License
MIT
All versions of cloudflare-browser with dependencies
symfony/serializer Version ^7
crell/serde Version ^1.3
amphp/http-client Version ^5.3
spiral/json-schema-generator Version ^1.1
symfony/property-access Version ^7