In-Touch / laravel-newrelic

Laravel NewRelic ServiceProvider
173 stars 48 forks source link

Lumen support #30

Open nnnikolay opened 9 years ago

nnnikolay commented 9 years ago

Do you have plan to support Lumen ?

Currently it does not work because of NewrelicServiceProvider and $app['router'] usage.

pleckey commented 9 years ago

@nnnikolay currently we aren't using Lumen for any projects, but I'm not against it. Happy to review a PR if it doesn't create any BC breaks.

nnnikolay commented 9 years ago

@pleckey I would love to do that. But there are few issue so far...

$app->middleware([
    App\Http\Middleware\LumenNewrelicMiddleware::class
 ]);
            ...
            class_alias('Illuminate\Support\Facades\Cache', 'Cache');
            class_alias('Illuminate\Support\Facades\Cookie', 'Cookie');
            ...

it means we need to add similar line into the bootstrap/app.php

class_alias('Intouch\LaravelNewrelic\Facades\Newrelic', 'Newrelic');

Seems now it should work :)

wirtsi commented 8 years ago

In the LumenNewRelicMiddleWare (around line 95), could you please rewrite

foreach (\App::getRoutes() as $routeName => $route) {
            $regex = $routeToRegex($routeName);
            $method = $routeToMethod($routeName);
            $routes[$method.$regex] = compact('route', 'method', 'regex');
        }

to

        foreach (app()->getRoutes() as $routeName => $route) {
            $regex = $routeToRegex($routeName);
            $method = $routeToMethod($routeName);
            $routes[$method.$regex] = compact('route', 'method', 'regex');
        }

so it also works without the Facades being enabled

bests & thanks wirtsi

razvanphp commented 8 years ago

I got another problem with Lumen when running

vagrant@server:~/feed-api$ php artisan vendor:publish --provider="Intouch\LaravelNewrelic\NewrelicServiceProvider"
PHP Fatal error:  Call to undefined function Intouch\LaravelNewrelic\config_path() in /home/vagrant/feed-api/vendor/intouch/laravel-newrelic/src/Intouch/LaravelNewrelic/NewrelicServiceProvider.php on line 41

  [Symfony\Component\Debug\Exception\FatalErrorException]
  Call to undefined function Intouch\LaravelNewrelic\config_path()

Is this related to Lumen - Laravel differences?

JuanKman94 commented 6 years ago

57 Using Lumen 5.5 app()->getRoutes() isn't working anymore