PHPackages                             darkwood/ia-exception-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. darkwood/ia-exception-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

darkwood/ia-exception-bundle
============================

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

v8.0.13(4w ago)2586↓50.4%MITPHPPHP &gt;=8.5

Since Feb 8Pushed 2w agoCompare

[ Source](https://github.com/darkwood-com/ia-exception-bundle)[ Packagist](https://packagist.org/packages/darkwood/ia-exception-bundle)[ RSS](/packages/darkwood-ia-exception-bundle/feed)WikiDiscussions 8.1 Synced 3w ago

READMEChangelog (8)Dependencies (28)Versions (10)Used By (0)

Darkwood IaExceptionBundle
==========================

[](#darkwood-iaexceptionbundle)

[![Darkwood IA exception error page](docs/error-page-screenshot.png)](docs/error-page-screenshot.png)

Augments HTTP 500 errors with AI-based exception analysis using [Symfony AI](https://symfony.com/doc/current/ai/bundles/ai-bundle.html). Instead of a raw stack trace, you get a clear explanation, probable causes, and suggested fixes—generated by an LLM.

Requirements
------------

[](#requirements)

- PHP 8.5+
- Symfony 8.x
- [symfony/ai-bundle](https://packagist.org/packages/symfony/ai-bundle) (with a configured platform and agent)

Installation
------------

[](#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](https://symfony.com/doc/current/ai/bundles/ai-bundle.html) (e.g. OpenAI):

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

Configuration
-------------

[](#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)

[](#async-ai-analysis-symfony-uxstyle)

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

[](#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
--------------

[](#output-formats)

### JSON (`Accept: application/json`)

[](#json-accept-applicationjson)

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)

[](#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
-----------------------

[](#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
-----------

[](#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
-------

[](#license)

[MIT](LICENSE.md) - Mathieu Ledru 2026

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance96

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~1 days

Total

10

Last Release

28d ago

Major Versions

1.x-dev → 8.0.x-dev2026-05-27

PHP version history (2 changes)v1.0.0PHP &gt;=8.2

1.0.x-devPHP &gt;=8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/97714c2a86385f953811112ab18938b453bc0f826f91753730037ad5f9c7dbe9?d=identicon)[matyo91](/maintainers/matyo91)

---

Top Contributors

[![matyo91](https://avatars.githubusercontent.com/u/1254025?v=4)](https://github.com/matyo91 "matyo91 (8 commits)")

---

Tags

exception-handleriaphpsymfonysymfony-aisymfony-bundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darkwood-ia-exception-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/darkwood-ia-exception-bundle/health.svg)](https://phpackages.com/packages/darkwood-ia-exception-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M374](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
