dev-master
9999999-dev https://github.com/knyga/yii-newrelicWrapper around the New Relic PHP API.
GNU
The Requires
- php >= 5.4
- lib-curl *
by Paul Lowndes
yii newrelic knyga gtcode
Wrapper around the New Relic PHP API.
Yii wrapper around the New Relic PHP API., (*1)
yii-newrelic is a wrapper around the New Relic PHP API. Automatic tracking of module/controller/action ID's is supported. Automatic injection of timing header and footer also supported., (*2)
1) Install the New Relic PHP driver on your web server per New Relic For PHP instructions., (*3)
2) Install package via composer, (*4)
Install Composer to your project root:, (*5)
curl -sS https://getcomposer.org/installer | php
Add a composer.json
file to your project:, (*6)
{ "require": { "knyga/yii-newrelic": "dev-master" } }
Run the Composer installer:, (*7)
php composer.phar install
3) In main.php add line to define vendor path:, (*8)
Yii::setPathOfAlias('vendor', dirname(__FILE__) . '/../../../vendor');
And add the following to 'components':, (*9)
'newRelic' => [ 'class' => 'vendor.knyga.yii-newrelic.YiiNewRelic', ], 'clientScript' => [ 'class' => 'vendor.knyga.yii-newrelic.YiiNewRelicClientScript', ],
4) If you are using a script that subclasses CClientScript
, instead of adding
'clientScript' to your 'components', you will instead need to orphan that
extension's script and extend it from YiiNewRelicClientScript
instead. To do so,
change extends CClientScript
to extends YiiNewRelicClientScript
, and then
add a line before that class declaration that says:, (*10)
Yii::import('vendor.knyga.yii-newrelic.YiiNewRelicClientScript');
Or add line to import block in your main.php:, (*11)
'import' => [ 'vendor.knyga.yii-newrelic.YiiNewRelicClientScript' ]
5) In main.php, add the following to the top-level array:, (*12)
'behaviors' => [ 'newRelic' => [ 'class' => 'vendor.knyga.yii-newrelic.behaviors.YiiNewRelicWebAppBehavior', ] ],
6) Create subclass of CWebApplication
, e.g. NewRelicApplication
., (*13)
7) In this new class, e.g. NewRelicApplication
, add a method::, (*14)
public function beforeControllerAction($controller, $action) { Yii::app()->newRelic->setTransactionName($controller->id, $action->id); return parent::beforeControllerAction($controller, $action); }
8) To use your new subclassed CWebApplication
, modify index.php similar to:, (*15)
$config=dirname(__FILE__).'/../protected/config/main.php'; require_once(dirname(__FILE__).'/../yii-1.1.12.b600af/framework/yii.php'); require_once(dirname(__FILE__).'/../protected/components/system/PromocastApplication.php'); $app = new NewRelicApplication($config); $app->run();
9) In console.php, add the following to 'components':, (*16)
'newRelic' => [ 'class' => 'vendor.knyga.yii-newrelic.YiiNewRelic', ],
10) In console.php, add the following to the top-level array:, (*17)
'behaviors' => [ 'newRelic' => [ 'class' => 'vendor.knyga.yii-newrelic.behaviors.YiiNewRelicConsoleAppBehavior', ], ],
Modified BSD License https://github.com/gtcode/yii-newrelic, (*18)
Wrapper around the New Relic PHP API.
GNU
yii newrelic knyga gtcode