PHPackages                             raffaelecarelle/php-error-insight-symfony-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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. raffaelecarelle/php-error-insight-symfony-bundle

ActiveSymfony-bundle[Debugging &amp; Profiling](/categories/debugging)

raffaelecarelle/php-error-insight-symfony-bundle
================================================

Symfony Bundle for PHP Error Insight - AI-powered error handling for Symfony applications

1.0.17(6mo ago)1528↓33.3%GPL-3.0-or-laterPHPPHP &gt;=8.1CI passing

Since Sep 19Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/raffaelecarelle/Php-Error-Insight-Symfony-Bundle)[ Packagist](https://packagist.org/packages/raffaelecarelle/php-error-insight-symfony-bundle)[ RSS](/packages/raffaelecarelle-php-error-insight-symfony-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (19)Used By (0)

PHP Error Insight Symfony Bundle
================================

[](#php-error-insight-symfony-bundle)

A Symfony bundle that integrates [PHP Error Insight](https://github.com/raffaelecarelle/php-error-insight) to provide AI‑assisted explanations and richer error pages for HTTP and Console errors.

Screenshots:

[![screenview1.png](src/Resources/img/readme/screenview1.png)](src/Resources/img/readme/screenview1.png)[![screenview2.png](src/Resources/img/readme/screenview2.png)](src/Resources/img/readme/screenview2.png)[![terminal.png](src/Resources/img/readme/terminal.png)](src/Resources/img/readme/terminal.png)

Features
--------

[](#features)

- 🔍 AI‑assisted error explanations (optional, multiple backends)
- 🎨 Enhanced HTML/text/JSON rendering provided by the core library
- ⚡ Seamless Symfony integration for HTTP exceptions and Console errors
- 🔧 Highly configurable: choose backend, model, output, verbosity and paths

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

[](#requirements)

- PHP &gt;= 8.1
- Symfony &gt;= 5.4
- Composer

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

[](#installation)

Install the bundle (typically in dev/test):

```
composer require --dev raffaelecarelle/php-error-insight-symfony-bundle
```

### Configure Symfony Runtime error handler (required)

[](#configure-symfony-runtime-error-handler-required)

To enable the bundle's PHP error handling, you must tell Symfony Runtime to use this bundle's error handler. Add the following to your application's `composer.json` under the `extra.runtime` section, then regenerate the autoloader:

```
{
  "extra": {
    "runtime": {
      "error_handler": "PhpErrorInsightBundle\\Handler\\ErrorHandler"
    }
  }
}
```

After editing composer.json, run:

```
composer dump-autoload
```

Notes:

- The configuration must live in your application root `composer.json` (not in a dependency).
- This requires the `symfony/runtime` Composer plugin to be allowed in your project (see `config.allow-plugins["symfony/runtime"]`).

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

[](#configuration)

The bundle exposes a single configuration root: `php_error_insight`.

### Basic configuration

[](#basic-configuration)

Create or update `config/packages/php_error_insight.yaml`:

```
php_error_insight:
    enabled: true
    backend: 'none'   # or: local, api, openai, anthropic, google, gemini
    language: 'en'
    output: 'auto'    # or: html, text, json
```

### Advanced configuration

[](#advanced-configuration)

```
php_error_insight:
    enabled: true
    backend: 'local'
    model: 'llama3:instruct'
    api_url: 'http://localhost:11434'
    language: 'en'
    output: 'html'
    verbose: false

    # Absolute path of your project inside the running environment
    # (e.g. "/app" inside a Docker container)
    project_root: '%kernel.project_dir%'

    # Optional: absolute path of the project on the host machine to map
    # container paths to host paths when rendering links
    host_root: '/absolute/path/on/host'

    # Optional: custom HTML template supported by the core library
    template: null

    # Optional: editor URL pattern, e.g. "phpstorm://open?file=%file%&line=%line%"
    editor_url: null

    # API key for external backends (openai, anthropic, google/gemini, custom api)
    api_key: null
```

Notes:

- `backend` supports: `none`, `local`, `api`, `openai`, `anthropic`, `google`, `gemini`.
- When using local backends (e.g. Ollama), set `api_url` to your local endpoint.
- Use `project_root` and optionally `host_root` to make editor links and paths resolve correctly across containers/hosts.
- `editor_url` placeholders supported by the core renderer are typically `%file%` and `%line%`.

### Environment variables

[](#environment-variables)

You can configure via environment variables as well (e.g. in `.env.local`):

```
PHP_ERROR_INSIGHT_ENABLED=true
PHP_ERROR_INSIGHT_BACKEND=local
PHP_ERROR_INSIGHT_MODEL=llama3:instruct
PHP_ERROR_INSIGHT_API_URL=http://localhost:11434
PHP_ERROR_INSIGHT_LANG=en
PHP_ERROR_INSIGHT_OUTPUT=html
PHP_ERROR_INSIGHT_VERBOSE=false
PHP_ERROR_INSIGHT_PROJECT_ROOT=/app
PHP_ERROR_INSIGHT_HOST_ROOT=/Users/you/Projects/acme
PHP_ERROR_INSIGHT_EDITOR="phpstorm://open?file=%file%&line=%line%"
PHP_ERROR_INSIGHT_API_KEY=your-key-if-needed
```

Backend configuration examples
------------------------------

[](#backend-configuration-examples)

### 1) Local AI (Ollama)

[](#1-local-ai-ollama)

```
php_error_insight:
    backend: 'local'
    model: 'llama3:instruct'
    api_url: 'http://localhost:11434'
```

### 2) OpenAI

[](#2-openai)

```
php_error_insight:
    backend: 'openai'
    model: 'gpt-4o-mini'
    api_key: 'sk-your-openai-api-key'
```

### 3) Anthropic Claude

[](#3-anthropic-claude)

```
php_error_insight:
    backend: 'anthropic'
    model: 'claude-3-5-sonnet-20240620'
    api_key: 'your-anthropic-api-key'
```

### 4) Google (Generative AI)

[](#4-google-generative-ai)

```
php_error_insight:
    backend: 'google'
    model: 'gemini-1.5-flash'
    api_key: 'your-google-api-key'
```

### 5) Gemini (alias backend)

[](#5-gemini-alias-backend)

```
php_error_insight:
    backend: 'gemini'
    model: 'gemini-1.5-flash'
    api_key: 'your-google-api-key'
```

Usage
-----

[](#usage)

### HTTP exceptions

[](#http-exceptions)

The bundle registers a high‑priority listener for `kernel.exception`. When `enabled` is true, exceptions are rendered using PHP Error Insight’s renderer. If rendering fails or produces empty output, Symfony’s default error handling is used.

### Console errors

[](#console-errors)

A console event subscriber listens to `ConsoleEvents::ERROR` and, when `enabled`, prints the rendered output to the console. If rendering fails or produces empty output, normal console error output is preserved.

### Programmatic usage

[](#programmatic-usage)

You can call the service directly:

```
use PhpErrorInsightBundle\Service\ErrorInsightService;

final class YourController
{
    public function __construct(private ErrorInsightService $errorInsightService) {}

    public function someAction(): Response
    {
        try {
            // ... your code
        } catch (\Throwable $e) {
            if ($this->errorInsightService->isEnabled()) {
                $html = $this->errorInsightService->renderException($e);
                // do something with $html (log, email, custom response, ...)
            }

            throw $e; // keep default handling flow
        }
    }
}
```

Service IDs:

- `PhpErrorInsightBundle\Service\ErrorInsightService` (autowired)
- Alias: `php_error_insight.service`

How it works
------------

[](#how-it-works)

1. Exception interception (HTTP) via `kernel.exception` listener
2. Error interception (Console) via `ConsoleEvents::ERROR` subscriber
3. The bundle builds a Config and delegates rendering to the core library
4. Graceful fallback to Symfony’s default error handling when needed

Environment considerations
--------------------------

[](#environment-considerations)

It’s recommended to enable the bundle only in `dev` and/or `test`. You control this through:

- `config/bundles.php` (register the bundle for specific environments)
- `php_error_insight.enabled` setting per environment config

Customization
-------------

[](#customization)

- `template`: path to a custom HTML template supported by the core renderer
- `editor_url`: URL pattern to open files in your editor (e.g. PhpStorm)
- `project_root` / `host_root`: map paths correctly between container and host

Troubleshooting
---------------

[](#troubleshooting)

- Ensure the bundle is registered for the environment you’re using
- Verify `php_error_insight.enabled` is true for that environment
- For local backends, ensure your local service (e.g. Ollama) is running
- For API backends, verify `api_key` and reachability of `api_url` if applicable
- Check your logs for errors from the renderer or backend

Development
-----------

[](#development)

Run tests:

```
composer install
composer test
```

Quality tools:

```
composer quality
composer fix-all
```

License
-------

[](#license)

This bundle is licensed under the GPL-3.0-or-later license. See [LICENSE](LICENSE) for details.

Related
-------

[](#related)

- [PHP Error Insight](https://github.com/raffaelecarelle/php-error-insight)
- [Symfony](https://symfony.com)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance69

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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 ~3 days

Total

17

Last Release

191d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/470d7f2b64c268ccd0d73d1d19da604f5049ffdc717170df28ac460d34b8a327?d=identicon)[raffaelecarelle](/maintainers/raffaelecarelle)

---

Top Contributors

[![raffaelecarelle](https://avatars.githubusercontent.com/u/15015792?v=4)](https://github.com/raffaelecarelle "raffaelecarelle (77 commits)")

---

Tags

symfonybundleaidebuggingexception handlingerror handling

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/raffaelecarelle-php-error-insight-symfony-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/raffaelecarelle-php-error-insight-symfony-bundle/health.svg)](https://phpackages.com/packages/raffaelecarelle-php-error-insight-symfony-bundle)
```

###  Alternatives

[jolicode/gif-exception-bundle

The GhostBuster of your exception page

20596.8k](/packages/jolicode-gif-exception-bundle)[koriym/xdebug-mcp

Universal PHP Xdebug MCP Server with AI-optimized debugging support

4011.6k1](/packages/koriym-xdebug-mcp)[symfony/ai-mate

AI development assistant MCP server for Symfony projects

1624.9k11](/packages/symfony-ai-mate)[polcode/unit-converter-bundle

This bundle allows you to manage values in different units by simply command

1017.5k](/packages/polcode-unit-converter-bundle)

PHPackages © 2026

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