mdx-dev / li3_newrelic
一个用于New Relic的Lithium PHP插件
dev-master
2016-03-08 15:31 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-14 12:51:56 UTC
README
New Relic插件,用于Lithium PHP应用程序。
安装
Composer
{
"require": {
...
"mdx-dev/li3_newrelic": "dev-master"
...
}
}
php composer.phar install
子模块
git submodule add git://github.com/mdx-dev/li3_newrelic.git libraries/li3_newrelic
直接克隆
git clone git://github.com/mdx-dev/li3_newrelic.git libraries/li3_newrelic
设置
如果您没有提供shouldRun键,将提供一个通用的闭包,与下面的示例相同。
<?php // ... Libraries::add('li3_newrelic', array( 'shouldRun' => function() { return Environment::is('production') && extension_loaded('newrelic'); } )); // ... ?>
用法
Newrelic扩展在它们内置的函数调用周围提供了一个面向对象的包装器,因此调用Newrelic::notice_error会调用newrelic_notice_error。以下是可用的PHP New Relic函数列表。
<?php namespace app\controllers; use Exception; use li3_newrelic\extensions\Newrelic; class UserController extends \lithium\action\Controller { function create() { try { // some fun stuff here! } catch (Exception $e) { // Magic Newrelic::notice_error('UserCreate/Error', $e); } } ?>