


Deliverer, the PHP code savior you have been waiting for for so long, is here!
When a piece of code cannot see the complete call chain, do you need a tool to assist in clearly querying the entire complete call chain? This time the editor will take you to learn about Deliverer in php, so you no longer have to worry about code troubleshooting.
A few days ago, a group friend took over a piece of ancestral code. After troubleshooting for a long time, it was not solved. He prepared to run away with the bucket and finally helped him solve it. The complete process can be found at https:/ /mengkang.net/1470.html However, the positioning of the final code is based on my personal experience. The actual link called is different from what I expected, and it is all based on guesswork. I didn't see the complete call chain, so I thought I needed a tool to assist in explicitly querying the entire call chain.
So I built this tool, mainly for unfamiliar projects and online scenarios that are difficult to reproduce in daily environments.
deliver The ancestral code escape rescuer https://github.com/zhoumengka...
If your project is not that bad and the daily environment is ok, then it is best to be familiar with a project The method is still xdebug. This tool is mainly used to troubleshoot online problems.
Similar tools include 360's phptrace implementation principle, which is slightly different
Function points
can be based on the function name, class name, Use the method name and route to filter the output
You can exit after querying the specified filtered content n times
You can play back the entire request based on the request id The complete call chain
The filtered content will be highlighted
If the call stack is deep, you can specify -l to hide the display of deep calls.
Principle
In fact, it is relatively simple. It is divided into two steps. The first step is to collect logs and the second step is to analyze the logs.
Step 1
In the PHP_MINIT stage, use zend_set_user_opcode_handler to set up the processing and analysis of three types of opcodes: ZEND_DO_UCALL, ZEND_DO_FCALL_BY_NAME, and ZEND_DO_FCALL.
Note that it will cover calls to some built-in functions and methods, and we can filter by type.
Then create a new log file in the PHP_RINIT stage and write the requested information
pid-ts sapi http_method http_url
During the request process, print the call stack information in the custom handler
Finally close the log in PHP_RSHUTDOWN Writing files
The second step
Use bin/deliverer to analyze and organize the collected logs. This is a php script, so I won’t go into details. .
Install and use
Compile
$ phpize $ ./configure --with-php-config=/usr/local/php/bin/php-config $ make && sudo make install
Configure php.ini
Append
[deliverer] extension=deliverer.so
Restart php-fpm
sudo service php-fpm restart
Use analysis tools
You can move ./bin/deliverer to where you think it is Suitable directory, if you run it in the current directory
$ chmod +x deliverer
with a piece of my own ancestral code (my blog) from long ago
$ ./bin/deliverer -t
, this will always monitor the execution of all php processes
$ ./bin/deliverer -tAction::initUser -n3 -l5
Value | Explanation | |
---|---|---|
Action::initUser | Filter requests containing this call | |
3 | Count three times and exit | |
5 | The function (method) calls the depth display, and up to 5 layers are displayed. The excess parts are marked at the end |
$ ./bin/deliverer -tSqlExecute::getAll -n1 -l3

Recommended learning:
The above is the detailed content of Deliverer, the PHP code savior you have been waiting for for so long, is here!. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.