samuelnogueira / zend-expressive-new-relic
Integrates New Relic with Zend Expressive
Installs: 35 199
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- php: ^7.3 || ^8.0
- mezzio/mezzio-router: ^3.1
- psr/http-server-middleware: ^1.0
Requires (Dev)
- guzzlehttp/psr7: 2.5.0
- phpstan/phpstan: 1.10.66
- phpunit/phpunit: 9.6.18
- squizlabs/php_codesniffer: 3.8.1
- vimeo/psalm: 4.30.0
Suggests
- ext-newrelic: Middleware will do nothing if this extension isn't loaded
README
PSR-15 Middleware for New Relic instrumentation of Mezzio apps.
⚠️ Will not work correctly in async applications (ex. Swoole Coroutine) ⚠️
Requirements
- PHP ^7.3 or ^8.0
- A Mezzio application (formerly Zend Expressive)
Installation
This package is installable and autoloadable via Composer as samuelnogueira/zend-expressive-new-relic.
composer require samuelnogueira/zend-expressive-new-relic
Example
<?php // config/pipeline.php use Samuelnogueira\ZendExpressiveNewRelic\Middleware\NewRelicMiddleware; use Samuelnogueira\ZendExpressiveNewRelic\Middleware\NewRelicTransactionNameMiddleware; use Mezzio\Router\Middleware\RouteMiddleware; use Mezzio\Application; return static function (Application $app): void { // (...) // Profiling middleware 2nd most outer middleware to profile everything if (extension_loaded('newrelic')) { $app->pipe(NewRelicMiddleware::class); } // (...) // Register the routing middleware in the middleware pipeline $app->pipe(RouteMiddleware::class); // Add more middleware here that needs to introspect the routing results; this // might include: // // - route-based authentication // - route-based validation // - etc. if (extension_loaded('newrelic')) { $app->pipe(NewRelicTransactionNameMiddleware::class); } // (...) };
The MIT License (MIT). Please see LICENSE for more information.