pinpoint-apm / pinpoint-php-aop
通过 php-parse 实现的简单 Aop 库
v4.0.0
2024-09-02 03:13 UTC
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- ext-pinpoint_php: ^0.5.2
- nikic/php-parser: ^5.0
Requires (Dev)
- ext-pinpoint_php: ^0.5.2
- guzzlehttp/guzzle: 8.0.x-dev
- mongodb/mongodb: v1.19.x-dev
- nikic/php-parser: ^5.0
- phpbench/phpbench: 1.0.0
- phpunit/phpunit: ^8
- predis/predis: ^3.0@alpha
README
问题
https://github.com/pinpoint-apm/pinpoint-c-agent/labels/php-aop
需求
- php 7.0 ~ php 8.3
- ext-pinpoint_php: "^0.5.2" ( 指南 📑 )
如何使用
1. 从 Packagist 导入
composer require pinpoint-apm/pinpoint-php-aop
2. 将 pinpoint 添加到您的入口文件(例如:index.php)
<?php require_once __DIR__."/../vendor/autoload.php"; // A writable path for caching AOP code, default is /tmp // define('AOP_CACHE_DIR',__DIR__.'/../Cache/'); // optional // API for register your own plugins eg: define('PP_REQ_PLUGINS', Pinpoint\Plugins\DefaultRequestPlugin::class); require_once __DIR__. '/../vendor/pinpoint-apm/pinpoint-php-aop/auto_pinpointed.php';
编写您自己的插件
仅限开发者
步骤
- 编写您自己的插件(如有需要)。以下是一些插件模板。
- 使用
AspectClassHandle
将目标类与插件类结合。
$classHandler = new AspectClassHandle(\yii\web\UrlManager::class); $classHandler->addJoinPoint('parseRequest', \Pinpoint\Plugins\yii2\UrlRule::class); $cls[] = $classHandler;
- 扩展
DefaultRequestPlugin
并实现joinedClassSet
。
示例
我们的测试项目
- 对于 yii2,Yii2PerRequestPlugins 示例
- pinpoint-c-agent/SimplePHP
- pinpoint-c-agent/cachethq
- pinpoint-c-agent/flarum
- pinpoint-c-agent/php_phpmyadmin
- pinpoint-c-agent/php_wordpress
工作原理
- 使用
nikic/PHP-Parser
生成粘合层代码 - 使用命名空间替换来重用插件或钩子内置类/函数
- 拦截 php 类加载器以将原始类重定向到新类
pinpoint-php-aop 使用 onBefore/onEnd/onException 套件包装您的类。
博客
支持的库/框架
库
框架
数据图表地图
有一些示例在 lib/pinpoint/test/Comparison/pinpoint/test
需要帮助/问题
版权
Copyright 2024-present NAVER Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://apache.ac.cn/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.