acseo / aierrorexplained-bundle
This bundle provides AI explaination when an error has occured
Package info
github.com/acseo/AIErrorExplainedBundle
Type:symfony-bundle
pkg:composer/acseo/aierrorexplained-bundle
v0.1.1
2023-03-02 18:19 UTC
Requires
- php: ^8.1
- openai-php/client: ^0.3
README
This bundle improove Symfony Official Error page with an AI Suggestion to fix the error.
It relies on OpenAI and its openai-php/client package, and it uses a cache mecanism in order to avoid calling OpenAI multiple times for the same exception.
In order to handle ALL exception, we will need to register a custom Error Handler in the Symfony Kernel. This is something that can be done with your composer.json file (see installation).
Installation
- Declare the Custom Error Handler in composer.json
... "extra": { ... "runtime": { "error_handler": "ACSEO\\AIErrorExplainedBundle\\Runtime\\Internal\\AIErrorHandler" } } ...
- Install the bundle using composer
composer require --dev acseo/aierrorexplained-bundle
- Enable the bundle in you Symfony project (already done with Flex)
<?php // config/bundles.php return [ ACSEO\AIErrorExplainedBundle\ACSEOAIErrorExplainedBundle::class => ['dev' => true],
- Register your OPEN AI key in
.envfile
# .env
OPENAI_CLIENT_KEY=sk-XXXXXX
- Declare a custom Error Controller
# config/packages/framework.yml when@dev: framework: error_controller: ACSEO\AIErrorExplainedBundle\Controller\ErrorController::show
And tadaaa 🎉, you are ready to have errors !
What you should see