jpcaparas/laravel-firecrawl

Interface with the Firecrawl API using Laravel
1,720 8
Install
composer require jpcaparas/laravel-firecrawl
Latest Version:v0.1
PHP:^8.2||^8.3||^8.4
Laravel:10 · 11 · 12
License:MIT
Last Updated:Apr 27, 2026
Links: GitHub  ·  Packagist
Maintainer: jpcaparas

Laravel Firecrawl API Client

run-tests

PHPStan

A Laravel package for seamlessly integrating with the Firecrawl API, allowing you to turn entire websites into LLM-ready markdown and extract structured data using AI.

Features

  • Extract - Get structured data from web pages with AI
  • Crawl - Scrape all URLs from a website and get their content in LLM-ready format
  • Map - Input a website and get all its URLs extremely fast
  • Scrape - Get content from a single URL in various formats
  • Search - Perform web searches with the Firecrawl API

Installation

You can install the package via composer:

composer require jpcaparas/laravel-firecrawl

You can publish the config file with:

php artisan vendor:publish --tag="laravel-firecrawl-config"

Configuration

Add your Firecrawl API key to your .env file:

FIRECRAWL_API_KEY=your_api_key_here

You can obtain an API key by signing up at Firecrawl.

Usage

Using the Facade

use JPCaparas\LaravelFirecrawl\Facades\LaravelFirecrawl;

// Extract structured data from URLs
$result = LaravelFirecrawl::extract()->extract(
    ['https://example.com'],
    'Extract company information',
    [
        'type' => 'object',
        'properties' => [
            'company_name' => ['type' => 'string'],
            'description' => ['type' => 'string']
        ]
    ]
);

// Get extraction results using the job ID
$extractionResults = LaravelFirecrawl::extract()->getExtractionStatus($result['id']);

Using Dependency Injection

use JPCaparas\LaravelFirecrawl\LaravelFirecrawl;

public function __construct(protected LaravelFirecrawl $firecrawl)
{
    // Constructor injection
}

public function extractData()
{
    $result = $this->firecrawl->extract()->extract(
        ['https://example.com'],
        'Extract company information',
        [
            'type' => 'object',
            'properties' => [
                'company_name' => ['type' => 'string'],
                'description' => ['type' => 'string']
            ]
        ]
    );
    
    return $result;
}

Available Services

Extract Service
// Extract data from URLs using AI
$result = LaravelFirecrawl::extract()->extract(
    ['https://example.com'],
    'Extract company information',
    [
        'type' => 'object',
        'properties' => [
            'company_name' => ['type' => 'string'],
            'description' => ['type' => 'string']
        ]
    ],
    true // Enable web search (optional)
);

// Get extraction status and results
$status = LaravelFirecrawl::extract()->getExtractionStatus($result['id']);
Crawl Service
// Crawl a website
$result = LaravelFirecrawl::crawl()->crawl('https://example.com', [
    'maxDepth' => 3,
    'allowExternalLinks' => false
]);

// Get crawl status and results
$status = LaravelFirecrawl::crawl()->getCrawlStatus($result['id']);
Map Service
// Map a website to get all URLs
$result = LaravelFirecrawl::map()->map('https://example.com', [
    'maxDepth' => 2
]);
Scrape Service
// Scrape a single URL
$result = LaravelFirecrawl::scrape()->scrape('https://example.com', [
    'outputFormat' => 'markdown',
    'includeScreenshot' => true
]);
Search Service
// Search the web
$result = LaravelFirecrawl::search()->search('search query', [
    'limit' => 10
]);

Command Line

You can view information about the Firecrawl API client using the included command:

php artisan firecrawl:info

This command displays:

  • API key status
  • Available services
  • Usage examples
Extract Commands

Extract structured data from web pages with AI:

php artisan firecrawl:extract --urls=https://en.wikipedia.org/wiki/WD-40 --prompt="Extract product information" --schema='{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"}}}'

Options:

  • --urls - Array of URLs to extract data from (can be specified multiple times)

  • --urls-from-file - Path to a file containing URLs, one per line

  • --prompt - The prompt to guide the extraction

  • --prompt-from-file - Path to a file containing the prompt text

  • --schema - JSON schema for structuring the extracted data (inline JSON)

  • --schema-from-file - Path to a JSON file containing the schema

  • --config-file - Path to a JSON configuration file containing all extract parameters

  • --web-search - Enable web search capability

  • --output - Save results to specified file path

Check the status of an extraction job:

php artisan firecrawl:extract-status {id} --wait

Options:

  • --wait - Wait for the extraction to complete
  • --poll-interval - Seconds to wait between status checks when using --wait
  • --output - Save results to specified file path

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.

Related Packages

padosoft/laravel-ai-search-providers

Plug-and-play Laravel package exposing a single contract over Brave Search, Tavi...

1,543 1
marquine/php-etl

Extract, Transform and Load data using PHP.

139,276 181
fab2s/yaetl

Widely Extended Nodal Extract-Transform-Load ETL Workflow AKA NEJTL or Nodal-Ext...

206,664 65
braseidon/scraper

Scraper is a multi-threaded CURL wrapper for Laravel 5 that is a highly efficien...

55 7
gidlov/copycat

A universal scraping tool that can be used for all kinds of data collection. You...

82,389 71

Version History

Version Released PHP Laravel License
v0.1 ^8.2||^8.3||^8.4 ^10.0||^11.0||^12.0 MIT