1. Go to this page and download the library: Download jpcaparas/laravel-firecrawl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jpcaparas / laravel-firecrawl example snippets
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']);
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;
}
// 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 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 a website to get all URLs
$result = LaravelFirecrawl::map()->map('https://example.com', [
'maxDepth' => 2
]);
// Scrape a single URL
$result = LaravelFirecrawl::scrape()->scrape('https://example.com', [
'outputFormat' => 'markdown',
'
// Search the web
$result = LaravelFirecrawl::search()->search('search query', [
'limit' => 10
]);