Skip to main content

Installation

The official PHP SDK is maintained in the Firecrawl monorepo at apps/php-sdk. To install the Firecrawl PHP SDK, add the dependency via Composer:
Requires PHP 8.1 or later.

Laravel Integration

The SDK includes first-class Laravel support with auto-discovery. After installing the package, publish the configuration file:
Then add your API key to your .env file:
The following environment variables are supported:

Usage

  1. Get an API key from firecrawl.dev
  2. Set the API key as an environment variable named FIRECRAWL_API_KEY, or pass it with FirecrawlClient::create(apiKey: ...)
Here is a quick example using the current SDK API surface:

Using the Laravel Facade

In a Laravel application you can use the Firecrawl facade or dependency injection:

Scraping a URL

To scrape a single URL, use the scrape method.

JSON Extraction

Extract structured JSON with JsonFormat via the scrape endpoint:

Crawling a Website

To crawl a website and wait for completion, use crawl.

Start a Crawl

Start a job without waiting using startCrawl.

Checking Crawl Status

Check crawl progress with getCrawlStatus.

Cancelling a Crawl

Cancel a running crawl with cancelCrawl.

Crawl Errors

Fetch crawl-level errors (if any) with getCrawlErrors.

Mapping a Website

Discover links on a site using map.

Searching the Web

Search with optional search settings using search.

Batch Scraping

Scrape multiple URLs in parallel using batchScrape.
For manual async control, use startBatchScrape, getBatchScrapeStatus, and cancelBatchScrape:

Agent

Run an AI-powered agent with agent.
With a JSON schema for structured output:
For manual async control, use startAgent, getAgentStatus, and cancelAgent:

Usage & Metrics

Check concurrency and remaining credits:

Browser

The PHP SDK includes Browser Sandbox helpers.

Create a Session

Execute Code

Scrape-Bound Interactive Session

Use a scrape job ID to run follow-up browser code in the same replayed context:
  • interact(...) runs code in the scrape-bound browser session (and initializes it on first use).
  • stopInteractiveBrowser(...) explicitly stops the interactive session when you are done.

List & Close Sessions

Configuration

FirecrawlClient::create() supports the following options:

Custom HTTP Client

You can pass a pre-configured GuzzleHttp\ClientInterface implementation to control connection pooling, middleware, proxy settings, and other HTTP features. When provided, the timeoutSeconds setting is ignored in favor of the client’s own configuration.

Error Handling

The SDK throws runtime exceptions under Firecrawl\Exceptions.
Are you an AI agent that needs a Firecrawl API key? See firecrawl.dev/agent-onboarding/SKILL.md for automated onboarding instructions.