首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

Larapanda: A Type-Safe Lightpanda Browser SDK for Laravel

最后更新于 经过

Larapanda: A Type-Safe Lightpanda Browser SDK for Laravel image

Larapanda is a Laravel SDK for Lightpanda , a headless browser written in Zig. The package handles runtime resolution between CLI binary and Docker, profile-based instance management, typed fetch results, and optional adapters for the Laravel AI SDK and MCP server.

Profile-Based Instance Management

Configuration is organized into named instance profiles. Each profile can override the global defaults for runtime mode, binary path, and Docker settings — making it straightforward to maintain separate profiles for general fetching, crawling, and AI tool sessions.

// config/larapanda.php
'instances' => [
'默认' => [],
'crawler' => [
'运行时' => 'cli' ,
'binary_path' => '/absolute/path/to/lightpanda' ,
],
'mcp' => [
'运行时' => 'docker' ,
],
],

Selecting a profile at call time uses the manager interface:

使用 Ferdiunal\Larapanda\Contracts\LarapandaManagerInterface ;
经理 = 应用程序 LarapandaManagerInterface ::班级 (英文):
$defaultClient = 经理 -> 实例 '默认' (英文):
$crawlerClient = 经理 -> 实例 'crawler' (英文):

Runtime Resolution

auto runtime prefers CLI execution when a valid binary_path is configured and the binary is executable, and falls back to Docker otherwise. You can also pin a profile to cli 或者 docker 明确地。

Typed Fetch Results

fetchRequest() 返回 FetchResult with strict accessors tied to the selected dump format. Calling a mismatched accessor throws UnexpectedFetchOutputFormatException rather than silently returning garbage data.

使用 Ferdiunal\Larapanda\Enums\FetchDumpFormat ;
$结果 = 客户端 -> fetchRequest 'https://example.com'
-> 带选项
倾倒 : FetchDumpFormat :: Markdown ,
obeyRobots : 真的 ,
waitMs : 2000 ,
-> 跑步 ();
$markdown = $结果 -> asMarkdown ();
// Semantic tree formats
$treeResult = 客户端 -> fetchRequest 'https://example.com'
-> 带选项 倾倒 : FetchDumpFormat :: SemanticTree
-> 跑步 ();
$tree = $treeResult -> asSemanticTree (); // array<string, mixed>

Proxy support is available per-request:

$结果 = 客户端 -> fetchRequest 'https://example.com'
-> 带选项
倾倒 : FetchDumpFormat :: Markdown ,
httpProxy : 'http://127.0.0.1:3000' ,
proxyBearerToken : 'MY-TOKEN' ,
-> 跑步 ();

Laravel AI SDK 集成

Larapanda exposes Lightpanda as tools for the Laravel AI SDK . The adapter is session-aware — passing the same session_id across tool calls keeps the browser session open between steps, which matters for multi-step browsing tasks.

作曲家 要求 laravel/ai laravel/mcp
使用 Ferdiunal\Larapanda\Integrations\Ai\LarapandaAiTools ;
使用 Illuminate\Support\Facades\AI ;
$响应 = 人工智能 :: 提供者 'openai'
-> 模型 'gpt-5-mini'
-> 迅速的 'Open laravel.com and return the main headings.'
-> 工具 应用程序 LarapandaAiTools ::班级 -> 制作 ())
-> 文本 ();

Tool names use the configured prefix (default lightpanda_ ): lightpanda_markdown , lightpanda_semantic_tree , lightpanda_click , and so on. You can restrict which tools the model sees via config:

“整合” => [
'ai' => [
'exposed_tools' => [ 'goto' , 'markdown' , 'semantic_tree' ],
],
],

MCP Server Adapter

For applications using the Laravel MCP server , Larapanda provides an adapter that registers Lightpanda tools with Laravel's container, applies profile-based runtime resolution, and shares the session pool and proxy policy with the AI SDK adapter.

// routes/ai.php
使用 Ferdiunal\Larapanda\Integrations\Mcp\LarapandaMcpServer ;
LarapandaMcpServer :: registerLocal 姓名 : 'lightpanda' (英文):

Session lifetime and pool size are controlled from config:

“整合” => [
'mcp' => [
'session_ttl_seconds' => 300 ,
'max_sessions' => 32 ,
'obey_robots' => 真的 ,
],
],

You can find the source and full documentation on GitHub

保罗·雷德蒙德照片

Laravel News 特约撰稿人。全栈 Web 开发人员兼作家。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Laravel 代码审查

几天内即可获得 Laravel 代码审查方面的专家指导

访问 Laravel 代码审查
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Generate HTML Password Rules Attribute in Laravel 13.9.0 image

Generate HTML Password Rules Attribute in Laravel 13.9.0

阅读文章
DHH Joins Laravel Live Denmark 2026 for Fireside Chat with Taylor Otwell image

DHH Joins Laravel Live Denmark 2026 for Fireside Chat with Taylor Otwell

阅读文章
Model-Based Scheduling for Laravel with Cadence image

Model-Based Scheduling for Laravel with Cadence

阅读文章
Laravel's AI SDK adds sub-agents image

Laravel's AI SDK adds sub-agents

阅读文章
Laravel Introduces First-Party Passkey Authentication Support image

Laravel Introduces First-Party Passkey Authentication Support

阅读文章
Scrollbar Styling and Container Size Utilities in Tailwind CSS v4.3.0 image

Scrollbar Styling and Container Size Utilities in Tailwind CSS v4.3.0

阅读文章