Symfony\Component\HttpFoundation\Request).EventDispatcher is replaced by Laravel’s Events system, requiring rewrites of event-driven logic (e.g., kernel.request → Illuminate\Http\Kernel events).RouteAwareTransactionNamer relies on Symfony’s Router; Laravel’s routing system would need a custom adapter.Symfony\Component\HttpKernel\Event\GetResponseEvent) must be mapped to Laravel equivalents (e.g., Illuminate\Http\Request, Illuminate\Events\Dispatcher).NewRelic facade (if available) or the native PHP agent as a fallback.laravel-newrelic-transaction-namer) to avoid tight coupling.config.yml; Laravel uses .env and config/services.php. Plan for a seamless migration path.NewRelicTransactionNamerMiddleware).Illuminate\Console\Kernel to instrument commands (similar to Symfony’s ConsoleCommandEvent).newrelic/newrelic (PHP agent), illuminate/support (for events/DI).spatie/laravel-newrelic (if partial functionality exists).NewRelic\Agent::setTransactionName())..env for NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME.TransactionNamerInterface to Laravel’s TransactionNamer contract.Illuminate\Console\Events\CommandStarting.NewRelic\Agent::addCustomParameter().^5.0 of the PHP agent for broad compatibility.EventDispatcher with Laravel’s Events facade.ContainerInterface to Laravel’s Illuminate\Container\Container.| Step | Task | Dependencies |
|---|---|---|
| 1 | Install New Relic PHP agent | Composer |
| 2 | Configure .env and config/services.php |
Agent installed |
| 3 | Create NewRelicTransactionNamerMiddleware |
Agent configured |
| 4 | Register middleware in app/Http/Kernel.php |
Middleware created |
| 5 | Instrument console commands | Middleware validated |
| 6 | Add custom attributes/event listeners | Core integration complete |
| 7 | Write tests and benchmark | All features implemented |
EventDispatcher → Laravel’s Events").App\Exceptions\Handler.storage/logs/laravel.log.laravel-debugbar).php -d memory_limit=-1 artisan command.NEW_RELIC_APP_NAME is consistent across environments (e.g., APP_ENV-based naming).newrelic.ini if needed.| Scenario | Impact | Mitigation |
|---|---|---|
| New Relic agent crashes | No APM data, but app remains functional | Use try-catch in middleware; log errors. |
| Transaction naming fails | Unlabeled transactions in New Relic UI | Fallback to default naming (e.g., NewRelic\Agent::getTransactionName()). |
| Console command instrumentation broken | Missing CLI metrics | Validate with artisan list --verbose. |
| Configuration errors (e.g., invalid license key) | Agent disabled; no data collected | Validate .env on deploy with php artisan config:clear. |
.env and monitor agent logs.docs/NEW_RELIC.md in the Laravel repo with:
route()->getName() instead of request->attributes->get('_route')").laravel-newrelic package (if available) as a reference.How can I help you explore Laravel packages today?