ai-os / error-agent
AI Engineering OS — PHP error capture & auto-fix agent for Laravel and any PHP project.
dev-main
2026-07-12 11:00 UTC
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-07-12 11:02:20 UTC
README
Capture PHP errors and send them to AI Engineering OS for centralized tracking and auto-fix.
Installation
composer require ai-os/error-agent
Laravel
1. Add to .env
AI_OS_API_URL=http://your-platform:3001 AI_OS_PROJECT_ID=your-project-uuid
2. Register Service Provider (auto-discovered by Laravel)
3. Publish config (optional)
php artisan vendor:publish --tag=error-agent-config
4. Override Exception Handler
In app/Exceptions/Handler.php:
use AiOs\ErrorAgent\ErrorAgent; public function register(): void { $this->reportable(function (Throwable $e) { ErrorAgent::capture($e, config('error-agent')); return false; }); }
Usage (any PHP)
use AiOs\ErrorAgent\ErrorAgent; $agent = new ErrorAgent([ 'apiUrl' => 'http://localhost:3001', 'projectId' => 'your-uuid', ]); try { // your code } catch (\Throwable $e) { $agent->send([ 'message' => $e->getMessage(), 'severity' => 'critical', 'stack' => $e->getTraceAsString(), 'projectType' => 'laravel', 'source' => 'agent', 'context' => [ 'file' => $e->getFile(), 'line' => $e->getLine(), ], ]); throw $e; } // Or static method ErrorAgent::capture($e, [ 'apiUrl' => 'http://localhost:3001', 'projectId' => 'your-uuid', ]);
Endpoint
POST /api/projects/:projectId/errors/log Content-Type: application/json { "message": "Error message", "severity": "critical", "stack": "#0 /var/www/...", "projectType": "laravel", "source": "agent", "context": { "file": "UserController.php", "line": 42 } }