承接 darkwood/ia-exception-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

darkwood/ia-exception-bundle

Composer 安装命令:

composer require darkwood/ia-exception-bundle

包简介

Augments HTTP 500 errors with AI-based exception analysis using Symfony AI

README 文档

README

Darkwood IA exception error page

Augments HTTP 500 errors with AI-based exception analysis using Symfony AI. Instead of a raw stack trace, you get a clear explanation, probable causes, and suggested fixes—generated by an LLM.

Requirements

Installation

composer require darkwood/ia-exception-bundle

Register the bundle in config/bundles.php (if not auto-registered):

return [
    // ...
    Darkwood\IaExceptionBundle\DarkwoodIaExceptionBundle::class => ['all' => true],
];

Configure Symfony AI (e.g. OpenAI):

# config/packages/ai.yaml
ai:
  platform:
    openai:
      api_key: '%env(OPENAI_API_KEY)%'
  agent:
    default:
      model: 'gpt-4o-mini'

Configuration

# config/packages/darkwood_ia_exception.yaml
darkwood_ia_exception:
  enabled: true                  # Opt-in; set true only when appropriate
  only_status_codes: [500]       # HTTP codes to augment
  agent: 'ai.agent.default'      # AI agent service ID
  timeout_ms: 800                # Target timeout (enforce via AI platform http_client)
  cache_ttl: 600                 # Cache TTL in seconds (0 = disabled)
  cache: 'cache.app'             # PSR-6 cache service
  include_trace: false           # Dev only; never true in production
  async: false                   # When true, AI analysis loads asynchronously (see below)
  async_route_prefix: '__ai_exception'
  async_context_ttl: 300        # Seconds to keep exception context for async (min 60)

Async AI analysis (Symfony UX–style)

When async: true, the exception page is returned immediately with standard content and a placeholder “AI analysis loading…”. No blocking AI call during kernel.exception. A small inline script then fetches the analysis from GET /__ai_exception/{error_id} and injects the result. If the request fails or times out (30s), a graceful fallback message is shown.

  • Requirement: Your app must import the bundle routes so the async endpoint is registered. In config/routes.yaml (or equivalent):
darkwood_ia_exception:
  resource: '@DarkwoodIaExceptionBundle/Resources/config/routes.yaml'
  • Production-safe: Async is configurable; leave async: false in production if you prefer synchronous behavior or do not expose the route.

Enforcing Timeout

To enforce the timeout at the HTTP level, configure a scoped HTTP client for your AI platform:

# config/packages/ai.yaml
framework:
  http_client:
    scoped_clients:
      ai.timeout_client:
        base_uri: 'https://api.openai.com'
        timeout: 0.8  # 800ms

ai:
  platform:
    openai:
      api_key: '%env(OPENAI_API_KEY)%'
      http_client: 'ai.timeout_client'

Output Formats

JSON (Accept: application/json)

Returns a structured JSON response:

{
  "error_id": "a1b2c3d4e5f6g7h8",
  "english_exception": "The database connection failed or a required table is missing.",
  "probable_causes": [
    "MySQL server is down or unreachable",
    "Database credentials are incorrect",
    "The specified database or table does not exist"
  ],
  "suggested_fixes": [
    "Verify the database server is running",
    "Check DB_HOST, DB_USER, DB_PASS, and DB_NAME in .env",
    "Run migrations if the schema is out of date"
  ],
  "confidence": 0.85
}

HTML (default)

The HTML template shows:

  • Error ID
  • AI-generated explanation
  • Probable causes
  • Suggested next steps
  • Confidence score
  • Original exception class and message
  • Disclaimer that results are hypotheses

Security Considerations

  • Never send secrets to the AI. The bundle sends only:
    • Exception class, message, file, line
    • Optionally: stack trace (when include_trace: true)
  • No environment variables, cookies, headers, or request payloads are ever sent.
  • include_trace should be true only in dev; traces can reveal paths and structure.
  • Use in production only with sanitized input (exception context) and after reviewing your exception messages for sensitive data.

Reliability

  • Fail-safe: If the AI fails, times out, or throws any error, the bundle does not set a response. Symfony’s default 500 handling runs as usual.
  • 500 is always returned: The response status remains 500; the bundle only augments the body.
  • Caching: Results are cached by a fingerprint (exception class, message, top frames hash) with configurable TTL to limit cost and repetition.

License

MIT - Mathieu Ledru 2026

darkwood/ia-exception-bundle 适用场景与选型建议

darkwood/ia-exception-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 996 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 darkwood/ia-exception-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 darkwood/ia-exception-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-08