doctorcode/sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

SDK_README_UPDATED.md

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

  1. Install the SDK - One command, no configuration files to edit
  2. Register at doctorcode.dev - Create your free account
  3. Add Your LLM API Keys - Manage your Claude, OpenAI, Grok, or Gemini keys through the web dashboard
  4. 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

  1. Visit doctorcode.dev/dashboard/api-keys
  2. Click "Add LLM Provider"
  3. Select your provider (Claude, OpenAI, Grok, or Gemini)
  4. Paste your API key
  5. 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:

  1. SDK captures the error - Automatically through exception handler
  2. Error sent to DoctorCode - Encrypted connection to DoctorCode API
  3. Your LLM key retrieved - Platform fetches your chosen LLM provider key
  4. AI analyzes the error - Using Claude, GPT-4o, Grok, or Gemini
  5. Fix generated - Working code solution with explanation
  6. 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

  1. Never commit API keys to version control
  2. Use dashboard to manage keys - Easier than managing .env files
  3. Rotate keys periodically - Easy to update through dashboard
  4. Use application-specific keys - Different keys for different apps if needed
  5. Monitor key usage - Check last_used_at timestamp 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

  1. Check that you're in production environment (or set DOCTORCODE_REPORT_LOCAL=true)
  2. Verify you've added an LLM API key at doctorcode.dev/dashboard
  3. 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

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 doctorcode/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 34
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-30