minhyung/error-solutions-gemini
最新稳定版本:0.1.0
Composer 安装命令:
composer require minhyung/error-solutions-gemini
包简介
Solution Provider using Gemini
README 文档
README
A spatie/error-solutions compatible Solution Provider powered by Google Gemini AI.
Requirements
- PHP 8.2+
- Composer
Installation
composer require minhyung/error-solutions-gemini
Basic Usage
use Minhyung\ErrorSolutionsGemini\Solutions\Gemini\GeminiSolutionProvider; use Spatie\ErrorSolutions\SolutionProviderRepository; $repository = new SolutionProviderRepository([ new GeminiSolutionProvider( apiKey: 'your-gemini-api-key', applicationType: 'PHP 8.3', applicationPath: __DIR__, ), ]); try { // Code that throws throw new \RuntimeException('Undefined variable $foo'); } catch (\Throwable $e) { $solutions = $repository->getSolutionsForThrowable($e); foreach ($solutions as $solution) { echo $solution->getSolutionTitle() . "\n"; echo $solution->getSolutionDescription() . "\n"; foreach ($solution->getDocumentationLinks() as $title => $url) { echo "- {$title}: {$url}\n"; } } }
Configuration
GeminiSolutionProvider constructor options
apiKey(required): Gemini API keycache(optional): PSR-16 cache implementationcacheTtlInSeconds(optional): Cache TTL, default 3600 secondsapplicationType(optional): Application type (e.g.,Laravel 11,Symfony 7)applicationPath(optional): Application root path for code snippet extractionmodel(optional): Gemini model, defaults toGemini\Enums\ModelType::GEMINI_FLASH
Cache usage example
use Psr\SimpleCache\CacheInterface; $provider = new GeminiSolutionProvider( apiKey: 'your-gemini-api-key', ); // Enable cache (optional) $provider->useCache($cache, cacheTtlInSeconds: 7200);
How It Works
- When an exception occurs, a prompt is built with file path, line number, code snippet, and the exception message.
- The prompt is sent to the Gemini API to request an AI-generated solution.
- The response is parsed to extract the fix (
FIX/ENDFIX) and related documentation links (LINKS/ENDLINKS). - When cache is enabled, repeat calls for the same exception are avoided.
minhyung/error-solutions-gemini 适用场景与选型建议
minhyung/error-solutions-gemini 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 minhyung/error-solutions-gemini 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 minhyung/error-solutions-gemini 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-30