jippi/cakephp-newrelic
Composer 安装命令:
composer require jippi/cakephp-newrelic
包简介
CakePHP <3 NewRelic
README 文档
README
CakePHP <3 NewRelic
You can modify your files like this
Things included
- NewRelic.NewRelic task
- NewRelic.NewRelic component
- NewRelicTrait trait
- NewRelic.NewRelic
Installation
composer require jippi/cakephp-newrelic Console
Include this snippet in app/Console/AppShell.php
public function startup() { $this->NewRelic = $this->Tasks->load('NewRelic.NewRelic'); $this->NewRelic->setName($this); $this->NewRelic->start(); $this->NewRelic->parameter('params', json_encode($this->params)); $this->NewRelic->parameter('args', json_encode($this->args)); parent::startup(); }
Controller
Simply add NewRelic.NewRelic to your $components list
app/webroot/index.php
Add this in top of your file before define('DS', 'DIRECTORY_SEPARATOR')
<?php require_once dirname(dirname(__DIR__)) . '/vendors/autoload.php'; if (extension_loaded('newrelic')) { $appType = 'app'; $appName = 'web'; if (strpos($_SERVER['REQUEST_URI'], '/admin/') !== false) { $appName = 'admin'; } define('NEW_RELIC_APP_NAME', sprintf('%1$s - %2$s - %3$s', 'production', $appType, $appName)); newrelic_set_appname(NEW_RELIC_APP_NAME); newrelic_background_job(false); newrelic_capture_params(true); } // Rest of your index.php here
app/Console/cake.php
<?php require_once dirname(dirname(__DIR__)) . '/vendors/autoload.php'; if (extension_loaded('newrelic')) { define('NEW_RELIC_APP_NAME', sprintf('%s - app - cli', 'production')); newrelic_set_appname(NEW_RELIC_APP_NAME); newrelic_background_job(true); newrelic_capture_params(true); } // Rest of your cake.php file here
Remark if using > CakePHP 3.3.0 and using middleware
If you utilise CakePHP middlewares from https://book.cakephp.org/3.0/en/controllers/middleware.html
You can use the supplied NewRelicErrorHandlerMiddleware placed in NewRelic\Middleware\NewRelicErrorHandlerMiddleware which extends the built in Cake\Error\Middleware\ErrorHandlerMiddleware. By using this you'll get the NewRelic working and have default CakePHP behavior.
Example:
<?php namespace App; use Cake\Http\BaseApplication; use Cake\Routing\Middleware\AssetMiddleware; use Cake\Routing\Middleware\RoutingMiddleware; /** * Application setup class. * * This defines the bootstrapping logic and middleware layers you * want to use in your application. */ class Application extends BaseApplication { /** * Setup the middleware your application will use. * * @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to setup. * @return \Cake\Http\MiddlewareQueue The updated middleware. */ public function middleware($middleware) { $middleware // Catch any exceptions in the lower layers, // and make an error page/response ->add(\NewRelic\Middleware\NewRelicErrorHandlerMiddleware::class) // Handle plugin/theme assets like CakePHP normally does. ->add(AssetMiddleware::class) // Apply routing ->add(RoutingMiddleware::class); return $middleware; } } ?>
jippi/cakephp-newrelic 适用场景与选型建议
jippi/cakephp-newrelic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 338.03k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「cakephp」 「newrelic」 「apm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jippi/cakephp-newrelic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jippi/cakephp-newrelic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jippi/cakephp-newrelic 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Polyfill for the New Relic PHP extension
Enhanced interaction with NewRelic from within a Symfony environment, ensuring optimal monitoring and logging for your applications
Laravel Newrelic integration
Email Toolkit Plugin for CakePHP
PHP Library for New Relic Agent
统计信息
- 总下载量: 338.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04