eeliu / php_simple_aop
此包已被弃用,不再维护。没有建议的替代包。
通过php-parse实现的简单Aop库
v1.0.0
2020-07-06 06:27 UTC
Requires
- nikic/php-parser: ^4.1
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2020-07-06 07:57:50 UTC
README
不再更新
如何使用
从packagist导入
在PHP/pinpoint_php_example/composer.json中更改配置文件
"require": { "eeliu/php_simple_aop": "v0.2.4" }
编写插件
这是一个参考的插件模板。
/// Placing "///@hook:" here: aop on function(method) on before,end and Exception ///@hook:app\AppDate::output class CommonPlugin { //$apId: The function(method) name //$who: If watching a method, $who is that instance //$args: array parameters $argv = $args[0] public function __construct($apId,$who,&...$args){ // $this->argv = $args[0]; // $this->funName =$apId; // $this->instance = $who; } // watching before ///@hook:app\DBcontrol::connectDb public function onBefore(){ } // watching after ///@hook:app\DBcontrol::getData1 app\DBcontrol::\array_push public function onEnd(&$ret){ } // Exception ///@hook:app\DBcontrol::getData2 public function onException($e){ } }
示例
https://github.com/naver/pinpoint-c-agent/tree/v0.2.2/PHP/pinpoint_php_example/Plugins
激活插件
可以在PHP/pinpoint_php_example/app/index.php中找到。
<?php require_once __DIR__."/../vendor/autoload.php"; // A writable path for caching AOP code define('AOP_CACHE_DIR',__DIR__.'/Cache/'); // Your plugins directory: All plugins must have a suffix "Plugin.php",as "CommonPlugin.php mysqlPlugin.php RPCPlugin.php" define('PLUGINS_DIR',__DIR__.'/../Plugins/'); // since 0.2.3 supports user filter when loadering a class. // define('USER_DEFINED_CLASS_MAP_IMPLEMENT','\Plugins\ClassMapInFile.php'); // Use php_simple_aop auto_pinpointed.php instead of vendor/autoload.php require_once __DIR__. '/../vendor/eeliu/php_simple_aop/auto_pinpointed.php';
工作原理
php_simple_aop使用onBefore/onEnd/onException套件包装您的类。
更多详细信息请参阅lib/pinpoint/test/Comparison/pinpoint/test
如果您发现了一个错误,请毫不犹豫地为我们创建一个issue。
如果它对您有帮助,请给我们一个星标以表示支持!谢谢!
版权
Copyright 2020 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.
