app-insights-php/doctrine-dependency-logger
Doctrine dependency logger for PHP that tracks and records Doctrine-related dependencies/events to help debug and understand runtime wiring. Useful for inspecting Doctrine configuration, service usage, and dependency resolution in apps using Doctrine ORM/DBAL.
DB::listen) and service container can be extended to leverage this package, but requires explicit instrumentation. The package does not natively support Laravel’s Eloquent ORM (only DBAL), which may limit adoption in Laravel-heavy codebases.Connection::getEventManager()). No major refactoring required for existing DBAL usage.DB::connection()->getEventManager() in a service provider.ext-curl for HTTP telemetry. May need proxy/configuration for air-gapped environments.TelemetryClient settings).DBAL\Connection instances).ext-curl and App Insights SDK compatibility.config('app-insights.enabled')).connection.init, statement.execute, and connection.close. Ensure no conflicts with other Doctrine listeners.DBAL\Connection..env for App Insights instrumentation key (avoid hardcoding).ext-curl if missing.// Example: Laravel Service Provider
public function register()
{
$this->app->bind(\Doctrine\DBAL\Connection::class, function ($app) {
$conn = new \Doctrine\DBAL\Connection([...]);
$logger = new \AppInsights\DoctrineDependencyLogger(
new \Microsoft\ApplicationInsights\Telemetry\TelemetryClient()
);
$conn->getEventManager()->addListener(...);
return $conn;
});
}
storage/logs/laravel.log.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| App Insights API unavailable | Lost telemetry (no blocking) | Fallback to Monolog/Stderr |
| Doctrine event listener fails | Silent logging drop | Add error handling wrapper |
| Instrumentation key invalid | All telemetry rejected | Validate key in CI/CD |
| Doctrine DBAL version mismatch | Runtime exceptions | Pin version in composer.json |
DB::connection()->executeQuery() for traced queries").How can I help you explore Laravel packages today?