Table of Contents
Configuring PhpStudy
Download the new version of PHP
Download and configure XDebug
Test whether the configuration is successful
Configure VS Code
Home Development Tools VSCode A brief analysis of how VSCode debugs the code in the PhpStudy environment

A brief analysis of how VSCode debugs the code in the PhpStudy environment

Dec 26, 2022 pm 08:02 PM
php vscode visual studio code

VSCodeHow to debug the code in PhpStudy? The following article will introduce to you how to use VSCode to debug the code in the PhpStudy environment. I hope it will be helpful to you!

A brief analysis of how VSCode debugs the code in the PhpStudy environment

In recent months, all projects have been moved to VS Code (except because of Unity debugging problems, they have been used back to Visual Studio).

During this period, I took some time to help a friend with a PHP project. However, I have never used the PHP debugging function. Suddenly I found a bug in a project, but I couldn't print anything, and no error was thrown. . This is outrageous. Ever since, I started to fill in my knowledge blind spots again, and I also wanted to use PHP's debugging function. [Recommended learning: vscode tutorial, Programming teaching]

Configuring PhpStudy


I am using WNMP Environment, the web server is Nginx, Apache environment is the same process.

Use the default version of PHP

Using the default version of PHP is quite simple, just open the XDebug debugging component That’s it.

A brief analysis of how VSCode debugs the code in the PhpStudy environment

After configuration, you can skip the following part and go directly to configure VS Code below.

Use a customized version of PHP

Why don’t I say that I am so slow in making things, because I often want to knowwhy and other methods. So instead of using the default PHP version, I wanted to update to the latest version of PHP 7.x.

Download the new version of PHP

First go to the official website to download the latest PHP 7.4.33 - windows.php.net/download, I make... nts version. After the download is completed, put it in the corresponding directory of phpstudy, for example X:\path\to\phpstudy_pro\Extensions\php. Change the folder name to the same rule, for example php-7.4.33nts.

Download and configure XDebug

The package just downloaded does not contain the XDebug plug-in, we need to download and configure it ourselves.

XDebug The official website has a very considerate function, which is to paste the information output by the local php_info into the input box, and it can help you analyze the information you want to download. version and give the download address. Enter the URL xdebug.org/wizard and click the *Analyse my phpinfo() output* button.

Copy the downloaded dll plug-in to the php-7.4.33nts\ext directory, and then add the following information to php.ini (add directly Just at the end, make sure it is after the OPCache configuration):

[XDebug]
zend_extension="D:\phpstudy_pro\Extensions\php\php-7.4.33nts\ext\php_xdebug.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.remote_autostart = 1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.remote_enable=On
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
Copy after login

Remember to change the value of zend_extension to the actual path and actual location of your plug-in name.

Test whether the configuration is successful

First restart the web server (whether Nginx or Apache), and then use phpinfo() to print the PHP information to see if There is XDebug plugin.

A brief analysis of how VSCode debugs the code in the PhpStudy environment

Configure VS Code


Make sure the PHP Debug plug-in has been downloaded in VSCode. You can search to download, or click here to jump to download - marketplace.visualstudio.com/items?itemN….

OpenFile->Preferences->Settings, add the following content in the configuration:

"php.validate.executablePath": "D:/phpstudy_pro/Extensions/php/php-7.4.33nts/php.exe"
Copy after login

Finally click *Run and Debug* button, add a configuration in the created launch.json, or find an existing configuration to modify:

{
    "name": "Listen for Xdebug",
    "type": "php",
    "request": "launch",
    "port": 9000
}
Copy after login

For more knowledge about VSCode, please visit : vscode basic tutorial!

The above is the detailed content of A brief analysis of how VSCode debugs the code in the PhpStudy environment. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

The Continued Use of PHP: Reasons for Its Endurance The Continued Use of PHP: Reasons for Its Endurance Apr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

How to debug vue project with vscode How to debug vue project with vscode Apr 16, 2025 am 07:00 AM

Steps to debug a Vue project in VS Code: Run the project: npm run serve or yarn serve Open the debugger: F5 or "Start debug" button Select "Vue: Attach to Chrome" configuration attached to the browser: VS Code automatically attached to the project running in Chrome Settings Breakpoint Start debug: F5 or "Start debug" button Step by step: Use the debug toolbar button to execute the code step by step Check variables: "Surveillance" window

See all articles