app-insights-php/app-insights-php-bundle
KernelTerminateListener), Monolog, Doctrine, and HTTP layers. This aligns well with Symfony-based Laravel-like architectures (e.g., Lumen, Symfony bridges in Laravel) but requires explicit adaptation for vanilla Laravel.HttpFoundation) may limit Laravel compatibility.HttpFoundation → Laravel’s Illuminate\Http.EventDispatcher → Laravel’s Events facade.Log facade.telemetryChannelContent).isSafe).| Laravel Component | Bundle Integration Path | Compatibility Notes |
|---|---|---|
| HTTP Requests | KernelTerminateListener → RequestTelemetry |
Replace Symfony’s Request with Laravel’s Request via facade/shim. |
| Logging (Monolog) | MonologHandler → App Insights traces |
Use Log::getMonolog() to bridge Laravel’s log to Monolog. |
| Doctrine DBAL | DoctrineLogger → SQL dependency tracking |
Works if using Doctrine; otherwise, implement custom QueryListener. |
| Exceptions | ExceptionListener → ExceptionTelemetry |
Laravel’s App\Exceptions\Handler can dispatch events to the bundle. |
| CLI (Artisan) | CliTelemetryCommand → Custom Artisan events |
Requires wrapping Artisan commands in events or using registerCommands(). |
| Custom Events | Manual TelemetryClient->trackEvent() calls |
Direct API usage bypasses Symfony listeners. |
| Twig (if used) | TelemetryTwigExtension → PageView tracking |
Only relevant if using Twig in Laravel (e.g., via Laravel Twig Bridge). |
Request → Laravel Request).APPINSIGHTS_INSTRUMENTATIONKEY in .env.config/packages/app_insights.yaml (or Laravel’s equivalent).app_insights:
telemetry:
enabled: true
disable_in_development: true
disable_in_test: true
disable_in_production: false
disable_in_cli: true # Disable CLI telemetry if not needed
monolog:
enabled: true
level: debug
doctrine:
enabled: true
twig:
enabled: false # Disable if not using Twig
config/services.php to avoid hardcoding.'app_insights' => [
'instrumentation_key' => env('APPINSIGHTS_INSTRUMENTATIONKEY'),
'telemetry' => [
'enabled' => env('APPINSIGHTS_ENABLED', false),
],
],
app-insights-php/app-insights-php-bundle and app-insights-php/app-insights-client to specific versions in composer.json.telemetryChannelContent).storage/logs/laravel.log.| Issue | Root Cause | Solution |
|---|---|---|
| Telemetry not appearing in Azure | Invalid INSTRUMENTATIONKEY |
Verify .env and Azure App Insights resource. |
| High latency | Network thrott |
How can I help you explore Laravel packages today?