In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the example of debugging PHP7 source code with VSCODE under WINDOWS. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
In the previous period of time involved in PHP extension development, there are debugging requirements for PHP source code, but most of the online debugging tutorials are under LINUX, very few under the WINDOWS system and the process is only a rough description. So I decided to try to set up a debugging environment under WINDOWS. After all, the principles are the same:).
1. Prepare for
The following is the configuration on my development machine, which can be consistent with me to reduce the chance of additional problems due to the tool version.
1.Visual Code source code editing and debugging tool
2.Visual Studio Community2017 (VS generally brings everything needed for development under WIN, after all, the whole family bucket of the universe.)
Red marked areas must be installed
3.PHP7 source code (you can also choose to pull it from github)
You can choose a packaged version of the source code at will
4.PHP7-SDK
My development machine is 64-bit, because it is compiling PHP7, I chose 64-bit deps-7.1-vc14-x64 (extended dependency library package), set up the php-sdk-binary-tools folder, extract the php-sdk-binary-tools-xxx.zip to this folder, set up the deps-vc14-x64 folder, and extract the deps-7.1-vc14-x64.7z to this folder.
At the same time, add the bin path in php-sdk-binary-tools to the WINDOWS system variable PATH. The deps-7.1-vc14-x64 article is not available for the time being, but you can download it first, because some of the libraries and headers that rely on compiling your own extensions are included, which you can use when you want to compile your own extensions:).
two。 Compile source code
After installing VS, run x64 Native Tools Command Prompt for VS 2017 under the Visual Studio 2017 folder in the start menu
After running, go to the PHP7 source code directory
1. Execute buildconf.bat to generate configure file (configure.js) under WIN
two。 You can run configure.bat-- help to view the supported compilation parameters
3. Execute configure.bat-- disable-all-- enable-cli-- enable-debug (to demonstrate simple compilation, you can add your own parameters)
4. Execute the nmake command to start compilation
With the native configuration, the compiled execution file is under x64/Debug_TS in the source code directory, and then you are ready to start debugging.
3. Debug using VSCODE
Debugging can be divided into two ways, one is additional process debugging, the other is running startup debugging, both of which will be introduced, first introduce running startup debugging.
First create a php source code file for testing, which I create in x64/Debug_TS under the source code directory.
Then select Debug-> Open the configuration and select C++ (Windows)
Finally, modify the configuration file as follows
We compiled the cli of PHP SAPI before, we opened the sapi/cli/php_cli.c source file, navigated to the main function on line 1197 and made a breakpoint.
Then we go to the DEBUG control panel of VS to run debugging.
Then you can see the breakpoint hit.
The debug configuration of the additional process is more or less the same. We click the menu option Debug-> Open the configuration, and select add configuration. In the pop-up selection list, select C _ Windows Attach + (debug) configuration.
The final configuration file is as follows:
Let's start a built-in server with PHP-S (the php must be the php.exe file you compiled) to make it easy to demonstrate additional process debugging. I started it in the same directory as the test.php file we created earlier.
The access results are as follows:
Start debugging in the same way, select (Windows) Attach to run in the debug panel of VSCODE.
Then select the PHP process from the pop-up process list and start debugging.
We use the array_push function in test.php. This time we go to the breakpoint of the implementation of this function, open ext/standard/array.c, navigate to line 2540, and hit the breakpoint.
The breakpoint can then be triggered by accessing http://127.0.0.1:8080/test.php in the browser.
This is the end of this article on "debugging PHP7 source code with VSCODE under WINDOWS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.