laravel/symfony-bundle) or Laravel’s Symfony integration (e.g., via symfony/http-foundation for HTTP requests).traceId-based log linking is a strong fit for distributed tracing in Laravel, where request IDs (e.g., X-Request-ID headers) are already common. This could integrate with Laravel’s built-in logging or third-party loggers like monolog.messenger in Symfony parlance). The bundle’s CLI transaction naming strategies could mirror Laravel’s command naming conventions.newrelic/newrelic). Laravel projects already using the agent would benefit from minimal additional setup.EventDispatcher, HttpFoundation), so integration would require:
events system can replace Symfony’s EventDispatcher for transaction/log hooks.Illuminate\Http\Request can be mapped to Symfony’s Request via adapters (e.g., symfony/http-foundation).Route objects would need translation to Laravel’s Route or Uri classes.Log facade can be extended to batch logs (via monolog) and inject traceId from Laravel’s context (e.g., request()->header('X-Request-ID')).symfony/http-foundation:^6.0).Route::get('/user', ...)) differs from Symfony’s (/user/_route). Custom naming strategies would need to be implemented.Command base class, requiring adapters or custom event listeners.logging.buffer_size) is beneficial but may require tuning for Laravel’s async logging (e.g., single vs. queue drivers).laravel/symfony-bundle or manually bridge Symfony components? What’s the trade-off in complexity?EventDispatcher in Laravel’s event system? (e.g., via SymfonyBridge or custom listeners).user.profile) map to Symfony’s route naming conventions? Custom strategies needed?traceId be propagated in Laravel’s context? (e.g., middleware for X-Request-ID or custom log context).queue:work, schedule:run) should be monitored? How will their names be formatted?logging.buffer_size for Laravel’s logging drivers (e.g., single, queue, slack)?HttpResponseException) be mapped to Symfony’s HttpException for exclusion rules?traceId propagation).symfony/http-foundation (for Request/Response adapters).symfony/event-dispatcher (for event listeners; replaceable with Laravel’s Events).symfony/console (for CLI transaction support; adapt Laravel’s Artisan commands).EventDispatcher → Use Laravel’s Events or a bridge like laravel/symfony-bundle.HttpKernel → Replace with Laravel’s middleware pipeline or custom RequestContext class.Command base class → Extend Laravel’s ConsoleCommand or wrap in a Symfony-compatible adapter.Phase 1: New Relic Agent Setup
newrelic/newrelic is installed and configured (newrelic.ini).Phase 2: Symfony Component Integration
composer require symfony/http-foundation symfony/event-dispatcher symfony/console
Symfony\Component\HttpFoundation\Request ↔ Illuminate\Http\Request.Symfony\Component\Console\Command ↔ Illuminate\Console\Command.Phase 3: Bundle Configuration
laravel/symfony-bundle) or create a Laravel config file mirroring Symfony’s structure.config/newrelic.php:
return [
'appname' => env('NEW_RELIC_APP_NAME', 'laravel_app'),
'license' => env('NEW_RELIC_LICENSE'),
'xmit' => false,
'logging' => [
'buffer_size' => 50,
],
'exclusions' => [
'transactions' => ['^ignored\.route$'],
'exceptions' => [\Symfony\Component\HttpKernel\Exception\HttpException::class],
],
];
Phase 4: Event Listeners
EventDispatcher with Laravel’s Events:
// Example: Log Laravel events to New Relic
Event::listen(\Illuminate\Http\KernelEvents::REQUEST, function ($request) {
$adapter = new SymfonyRequestAdapter($request);
// Use bundle's logic to push transaction/logs
});
Phase 5: CLI Transaction Support
Artisan to inject Symfony-style commands:
// Example: Wrap Artisan command in Symfony Command
class NewRelicCommand extends Symfony\Component\Console\Command\Command
{
protected function execute(InputInterface $input, OutputInterface $output)
{
// Delegate to Laravel's Artisan
Artisan::call('queue:work', [...]);
}
}
Phase 6: Log Correlation
Log facade to include traceId:
// In AppServiceProvider boot()
Log::extend('newrelic', function ($app) {
$handler = new NewRelicHandler(
$app['newrelic.logger'],
$app['request']->header('X-Request-ID')
);
return new Monolog\Logger('newrelic', [$handler]);
});
symfony/http-foundation:^5.4.monolog (Laravel’s default). Async drivers (e.g., queue) may need buffer tuning.traceId. Laravel’s Request middleware can handle this.config/newrelic.php.KernelEvents (HTTP) and ConsoleEvents (CLI).traceId.traceId.logging.buffer_size based on performance metrics.How can I help you explore Laravel packages today?