papi-ai/symfony
Composer 安装命令:
composer require papi-ai/symfony
包简介
Symfony bridge for PapiAI - Integrate AI agents into your Symfony application
README 文档
README
Symfony bridge for PapiAI -- integrate AI agents into your Symfony application with full dependency injection, configuration, and service wiring.
Installation
composer require papi-ai/symfony
Bundle Registration
If you are not using Symfony Flex, register the bundle manually in config/bundles.php:
return [ // ... PapiAI\Symfony\PapiBundle::class => ['all' => true], ];
Configuration
Create config/packages/papi.yaml:
papi: default_provider: openai providers: openai: driver: PapiAI\OpenAI\OpenAIProvider api_key: '%env(OPENAI_API_KEY)%' model: gpt-4o anthropic: driver: PapiAI\Anthropic\AnthropicProvider api_key: '%env(ANTHROPIC_API_KEY)%' model: claude-sonnet-4-20250514 middleware: - app.middleware.logging - app.middleware.rate_limit conversation: store: file path: '%kernel.project_dir%/var/papi/conversations'
Usage
Injecting a Provider
use PapiAI\Core\Contracts\ProviderInterface; class ChatController { public function __construct( private ProviderInterface $provider, ) {} public function chat(string $message): string { $response = $this->provider->chat([ ['role' => 'user', 'content' => $message], ]); return $response->getText(); } }
Using Conversation Storage
use PapiAI\Core\Contracts\ConversationStoreInterface; use PapiAI\Core\Conversation; class ConversationService { public function __construct( private ConversationStoreInterface $store, ) {} public function saveConversation(string $id, Conversation $conversation): void { $this->store->save($id, $conversation); } public function loadConversation(string $id): ?Conversation { return $this->store->load($id); } }
Using Doctrine Conversation Store
Install Doctrine DBAL and configure the store:
composer require doctrine/dbal
papi: conversation: store: doctrine
Create the conversations table in your database:
CREATE TABLE papi_conversations ( id VARCHAR(255) PRIMARY KEY, data JSON NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL );
Using Messenger Queue
Install Symfony Messenger:
composer require symfony/messenger
use PapiAI\Core\Contracts\QueueInterface; use PapiAI\Core\AgentJob; class AgentService { public function __construct( private QueueInterface $queue, ) {} public function dispatchJob(string $agentClass, string $prompt): string { $job = new AgentJob( agentClass: $agentClass, prompt: $prompt, ); return $this->queue->dispatch($job); } }
License
MIT License. See LICENSE for details.
papi-ai/symfony 适用场景与选型建议
papi-ai/symfony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 papi-ai/symfony 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 papi-ai/symfony 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-08