pinpoint-apm / pinpoint-php-aop
A simple Aop library via php-parse
v4.0.1
2024-10-21 03:19 UTC
Requires
- php: ^7.4 || ^8.0
- ext-json: *
- ext-pinpoint_php: ^0.6.0
- nikic/php-parser: ^5.0
Requires (Dev)
- ext-pinpoint_php: ^0.6.0
- 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
This package is auto-updated.
Last update: 2024-11-21 03:42:06 UTC
README
Issues
https://github.com/pinpoint-apm/pinpoint-c-agent/labels/php-aop
Requirements
- php 7.0 ~ php 8.3
- ext-pinpoint_php: "^0.5.2" ( Guide 📑 )
How to use
1. Import from packagist
composer require pinpoint-apm/pinpoint-php-aop
2. Add pinpoint entry into your entry file(eg: 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';
Write your own plugins
Only for developers
Steps
- Write your own plugins(if needs). Here are some plugins template.
- Use
AspectClassHandle
to combine target class with plugin class.
$classHandler = new AspectClassHandle(\yii\web\UrlManager::class); $classHandler->addJoinPoint('parseRequest', \Pinpoint\Plugins\yii2\UrlRule::class); $cls[] = $classHandler;
- Extend
DefaultRequestPlugin
and implementjoinedClassSet
.
Examples:
Our test project
- For yii2, Yii2PerRequestPlugins example
- pinpoint-c-agent/SimplePHP
- pinpoint-c-agent/cachethq
- pinpoint-c-agent/flarum
- pinpoint-c-agent/php_phpmyadmin
- pinpoint-c-agent/php_wordpress
How it works
- Use
nikic/PHP-Parser
generating glue layer code - Use namespace replace to reuse plugins or hook build-in class/function
- Intercept php classloader to redirect origin class to new class
pinpoint-php-aop wrappers your class with an onBefore/onEnd/onException suite.
Blog
Supported libraries/framework
Libraries
Frameworks
Data Chart Map
There are some examples into lib/pinpoint/test/Comparison/pinpoint/test
Needs Help/Issues
Copyright
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
http://www.apache.org/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.