定制 sanprojects/interceptor 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sanprojects/interceptor

最新稳定版本:1.0.21

Composer 安装命令:

composer require sanprojects/interceptor

包简介

Intercept php functions

README 文档

README

Intercepts external request in php scripts, and log it to STDERR. So you can better understand what doing your program.

Installation

composer require sanprojects/interceptor

Basic Usage:

// Intercept all kind of requests
\Sanprojects\Interceptor\Interceptor::interceptAll();

Now in the console you'll see something like this:

Interceptor.DEBUG: curl -vX POST 'https://www.example.com/' \ 
 --data 'postvar1=value1&postvar2=value2&postvar3=value3'
Interceptor.DEBUG: CURL> <!doctype html> ...
Interceptor.DEBUG: fopen /Users/san/PhpstormProjects/interceptor/tests/test.txt w+b [resource(stream)] 
Interceptor.DEBUG: fwrite /Users/san/PhpstormProjects/interceptor/tests/test.txt test 4 
Interceptor.DEBUG: fread /Users/san/PhpstormProjects/interceptor/tests/test.txt 100 test 
Interceptor.DEBUG: file_put_contents /Users/san/PhpstormProjects/interceptor/tests/test.txt test 4 
Interceptor.DEBUG: Redis::__construct NULL 
Interceptor.DEBUG: Redis tcp://127.0.0.1:6379 set test {"jsonKey":123} Predis\Response\Status 
Interceptor.DEBUG: Redis tcp://127.0.0.1:6379 get test {"jsonKey":123} 
Interceptor.DEBUG: mysqli_connect ensembldb.ensembl.org anonymous  mysqli 
Interceptor.DEBUG: mysqli_query ensembldb.ensembl.org SELECT 123 mysqli_result 
Interceptor.DEBUG: PDO::__construct mysql:dbname=;host=ensembldb.ensembl.org anonymous  NULL 
Interceptor.DEBUG: PDO::query SELECT 123 Sanprojects\Interceptor\Hooks\PDOStatement 
Interceptor.DEBUG: PDOStatement::execute SELECT 123; true

How it works

It use stream_wrapper_register to intercept included php files and stream_filter_register for rewrite source code.

Support

curl, fwrite, fread, file_get_contents, file_put_contents, mysqli, Redis, PDO, AMQP.

Caveats

  • It turns off opcache.
  • Because of source code injection, it can crush your app. Not all cases tested.

How to inject

Option 1: Run interceptor.phar

curl -O https://sanprojects.github.io/interceptor/interceptor.phar
php -d opcache.enable=0 interceptor.phar <yourScript.php>

Option 2: Use auto_prepend_file

curl -O https://sanprojects.github.io/interceptor/interceptor.phar
php -d opcache.enable=0 -d auto_prepend_file=interceptor.php <yourScript.php>

Option 1: Include in your script

\Sanprojects\Interceptor\Interceptor::interceptAll();

Option 2: Include php file in your script

require 'vendor/bin/interceptor.php';

Use it only for debug environment.

统计信息

  • 总下载量: 36.85k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-15