Skip to content

Instantly share code, notes, and snippets.

@migrs migrs/Kernel.php
Last active Apr 9, 2017

Embed
What would you like to do?
newrelic patch for laravel5.2
<?php namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
protected $middleware = [
\App\Http\Middleware\NewRelicPatch::class,
//... your other middlewares
];
//...
}
<?php
namespace App\Http\Middleware;
use Closure;
class NewRelicPatch
{
public function handle($request, Closure $next)
{
$response = $next($request);
event('router.filter:after:newrelic-patch', [$request, $response], true);
return $response;
}
}
<?php
Route::macro('after', function ($callback) {
$this->events->listen('router.filter:after:newrelic-patch', $callback);
});
@deehidayat

This comment has been minimized.

Copy link

commented Feb 10, 2016

thanks a Lot guys... this works for me.

@t202wes

This comment has been minimized.

Copy link

commented Feb 29, 2016

Where do you put the NewRelicPatch?

@juan55860

This comment has been minimized.

Copy link

commented Mar 3, 2016

Cheers!! Yet it´s valid ? I'm testing the patch, but it does not work.
I put this code and include 'newrelic-patch' how application route middleware.in Kernel.php in $routeMiddleware array and all my routes after the Route::macro(...);

@juan55860

This comment has been minimized.

Copy link

commented Mar 3, 2016

The patch function!!, only is wait a few minutes for the new relic agent report and you should to replace 'no_framework' for 'laravel' in 20-newrelic-ini, and execute php5dismod newrelic and latter php5enmod newrelic and restart php and apache or nginx services.

Thanks!. 👍 .

@adirickyk

This comment has been minimized.

Copy link

commented Apr 4, 2016

awesome, man !!!
Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.