doctorcode/sdk
Composer 安装命令:
composer require doctorcode/sdk
包简介
AI-powered error detection and fixing for PHP applications. Automatically captures errors and provides intelligent fixes using Claude, GPT-4, Grok, or Gemini.
README 文档
README
DoctorCode SDK
AI-powered error fixing for PHP and Laravel applications.
Zero-Configuration Installation
composer require doctorcode/sdk
That's it! The SDK automatically integrates with your Laravel application through service provider auto-discovery.
How It Works
- Install the SDK - One command, no configuration files to edit
- Register at doctorcode.dev - Create your free account
- Add Your LLM API Keys - Manage your Claude, OpenAI, Grok, or Gemini keys through the web dashboard
- Done! - All errors are automatically reported and analyzed by your chosen AI provider
Dashboard-Based Key Management
Instead of editing .env files, manage your LLM provider API keys through the user-friendly web dashboard at doctorcode.dev/dashboard.
Why Dashboard Management?
- Accessible to Everyone - No need to edit configuration files
- Privacy-First - Bring Your Own Keys (BYOK) model
- Multi-LLM Support - Switch between Claude Sonnet 4, GPT-4o, Grok, and Gemini Pro
- Secure - Keys encrypted at rest using Laravel encryption
- Multi-Application - Manage keys for all your applications from one place
Adding Your LLM Keys
- Visit doctorcode.dev/dashboard/api-keys
- Click "Add LLM Provider"
- Select your provider (Claude, OpenAI, Grok, or Gemini)
- Paste your API key
- Save - your applications will automatically use this key
Supported LLM Providers
| Provider | Model | Key Format |
|---|---|---|
| Claude | Sonnet 4 | sk-ant-... |
| OpenAI | GPT-4o | sk-... |
| Grok | Grok-2 | xai-... |
| Gemini | Pro | AIza... |
Features
Automatic Error Reporting
All uncaught PHP exceptions are automatically captured and sent to DoctorCode for analysis. No manual reporting required.
AI-Powered Fix Generation
Choose your preferred LLM provider. Each error is analyzed and a working fix is generated in ~30 seconds.
Privacy-First Architecture
- BYOK (Bring Your Own Keys) - You provide your own LLM API keys
- No Code Uploaded - Only error messages and stack traces are sent
- Encrypted Storage - All API keys encrypted using Laravel encryption
- Full Control - Manage and revoke keys anytime through the dashboard
Smart Error Detection
The SDK automatically filters out common exceptions like:
- Authentication errors
- Validation failures
- 404 Not Found errors
- Method Not Allowed errors
Environment-Aware
By default, errors are only reported in production environment. You can customize this behavior.
Requirements
- PHP 8.2 or higher
- Laravel 11.0 or higher
Advanced Configuration (Optional)
If you need to customize the SDK behavior, publish the configuration file:
php artisan vendor:publish --tag=doctorcode-config
This creates config/doctorcode.php with these options:
return [ // Base URL for DoctorCode API 'api_url' => env('DOCTORCODE_API_URL', 'https://doctorcode.dev/api'), // Enable/disable error reporting 'enabled' => env('DOCTORCODE_ENABLED', true), // Report errors in local environment 'report_local' => env('DOCTORCODE_REPORT_LOCAL', false), // Exceptions to skip reporting 'dont_report' => [ \Illuminate\Auth\AuthenticationException::class, \Illuminate\Validation\ValidationException::class, ], ];
Manual Error Reporting
You can manually report errors using the DoctorCode client:
use DoctorCode\SDK\DoctorCodeClient; $doctorCode = app(DoctorCodeClient::class); try { // Your code here } catch (\Exception $e) { $doctorCode->reportError( message: $e->getMessage(), file: $e->getFile(), line: $e->getLine(), stackTrace: $e->getTraceAsString() ); throw $e; }
Getting Fix Suggestions
use DoctorCode\SDK\DoctorCodeClient; $doctorCode = app(DoctorCodeClient::class); // Report an error and get the error ID $errorId = $doctorCode->reportError( message: 'Call to undefined method', file: 'app/Services/UserService.php', line: 42, stackTrace: $stackTrace ); // Get AI-generated fix $fix = $doctorCode->getFixSuggestion($errorId); if ($fix['success']) { echo "Suggested fix:\n"; echo $fix['fixed_code']; echo "\n\nExplanation:\n"; echo $fix['explanation']; }
How Error Analysis Works
When an error occurs:
- SDK captures the error - Automatically through exception handler
- Error sent to DoctorCode - Encrypted connection to DoctorCode API
- Your LLM key retrieved - Platform fetches your chosen LLM provider key
- AI analyzes the error - Using Claude, GPT-4o, Grok, or Gemini
- Fix generated - Working code solution with explanation
- Fix returned to you - View in dashboard or via API
Cost Control
Since you provide your own LLM API keys (BYOK model), you have complete control over costs:
- Claude API - ~$0.003 per error fix (Sonnet 4)
- OpenAI API - ~$0.002 per error fix (GPT-4o)
- Grok API - ~$0.001 per error fix
- Gemini API - Free tier available
You can monitor your API usage directly through your LLM provider's dashboard.
Security Best Practices
- Never commit API keys to version control
- Use dashboard to manage keys - Easier than managing
.envfiles - Rotate keys periodically - Easy to update through dashboard
- Use application-specific keys - Different keys for different apps if needed
- Monitor key usage - Check
last_used_attimestamp in dashboard
Community & Fix Sharing
DoctorCode builds a knowledge base of fixes. When an error has been fixed before:
- Instant fixes - No LLM call needed for known errors
- Improved accuracy - Learn from community-validated solutions
- Cost savings - Fewer LLM API calls
Troubleshooting
SDK Not Reporting Errors
- Check that you're in
productionenvironment (or setDOCTORCODE_REPORT_LOCAL=true) - Verify you've added an LLM API key at doctorcode.dev/dashboard
- Check Laravel logs for any DoctorCode connection errors
"No LLM Keys Configured" Message
Visit doctorcode.dev/dashboard/api-keys and add your preferred LLM provider's API key.
Invalid API Key Format
Make sure your API key matches the provider's format:
- Claude:
sk-ant-api03-... - OpenAI:
sk-... - Grok:
xai-... - Gemini:
AIza...
Support
- Documentation: docs.doctorcode.dev
- Issues: github.com/CLEDAI/doctor-code/issues
- Dashboard: doctorcode.dev/dashboard
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please see our contributing guidelines.
Get Started: https://doctorcode.dev
doctorcode/sdk 适用场景与选型建议
doctorcode/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debugging」 「laravel」 「ai」 「Gemini」 「grok」 「error-tracking」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 doctorcode/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 doctorcode/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 doctorcode/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.
Laravel Database Query Logger and debug helper.
A PHP security linter to detect insecure functions like var_dump, print_r, and other dangerous functions in your codebase
AI Agent templates for Laravel development - Skills, Agents, and Workflows for enhanced coding assistance
Profiler is a replica of Laravel Telescope modified for MongoDB.
AI discussion summaries for Flarum with real-time streaming.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-30