定制 jpcaparas/laravel-firecrawl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jpcaparas/laravel-firecrawl

Composer 安装命令:

composer require jpcaparas/laravel-firecrawl

包简介

Interface with the Firecrawl API using Laravel

README 文档

README

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.

jpcaparas/laravel-firecrawl 适用场景与选型建议

jpcaparas/laravel-firecrawl 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.46k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2025 年 05 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「extract」 「scrape」 「crawl」 「web scraping」 「llm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jpcaparas/laravel-firecrawl 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jpcaparas/laravel-firecrawl 我们能提供哪些服务?
定制开发 / 二次开发

基于 jpcaparas/laravel-firecrawl 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 29
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-01