Home Backend Development PHP Tutorial phpstorm配置Xdebug进行调试PHP教程_PHP

phpstorm配置Xdebug进行调试PHP教程_PHP

May 31, 2016 pm 06:15 PM
phpstorm xdebug Debugging php

运行环境:

PHPSTORM版本 : 8.0.1

PHP版本 : 5.6.2

xdebug版本:php_xdebug-2.2.5-5.6-vc11-x86_64.dll

ps : php版本和xdebug版本一定要相对应

1. PHP安装xdebug扩展

php.ini的配置,下面的配置仅供参考,路径要换成自己的!

[xdebug]

zend_extension=”D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll”

xdebug.remote_enable = On

xdebug.remote_handler = dbgp

xdebug.remote_host= localhost

xdebug.remote_port = 9000

xdebug.idekey = PHPSTORM

ps :  remote_handler 、 remote_host、 remote_port 这些都有默认值,但还是建议设置下,至少知道要设置这些参数~

查看phpinfo~

2.PHPSTORM设置

楼主以前一直用zendstudio,刚开始用phpstorm非常蛋疼,用了一段时间后发现还挺好用的~

1.首先检查phpstorm的xdebug配置

这里的debug port要和php.ini里面的 xdebug.remote_port相一致!默认是9000,如果9000端口被占用的话,可以改成其他端口。

2. 设置debug.

添加本地的 web server~

www.51open.pcom 是我本地的 web server~ ~

3.开始调试

打好第一个断点,shift + F9就可以了

打好 第一个断点 ,选中配置的debug,  按旁边的臭虫 按钮

 

总结:

根据断点配置,或在打开 Debug URL 的过程中,或在 POST 之后,如果 PhpStorm 监听到了 Debug 连接,就会立即切换到编辑器界面,并跳转到设置的断点处,浏览器端会等待 PhpStorm 的操作。

你可以随时中断 PhpStorm 的调试,或方便的进行 Step Into / Step Over / Run to cursor(这个刁爆了):

哎呀,不想调试了,PhpStorm 却总是跳出来?记得刚刚那个电话按钮嘛,再点一下,让其变成红色,就好了。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
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)

Will enabling XDebug on a production server make PHP slower? Will enabling XDebug on a production server make PHP slower? Sep 22, 2023 pm 10:41 PM

Yes, debuggers like XDebug can slow down PHP server performance. This is why the debugger is not placed in a server environment. They are deployed in different environments to avoid unnecessary overhead. Debug messages cannot be displayed in applications that are already in production. When debugging behavior is added to the server, the debugging engine is attached to the PHP process. It starts receiving messages to stop at the breakpoint, but this is not required behavior as it would give a performance hit to other processes, thus stopping the PHP parser. On the other hand, when debuggers are installed, they tend to open ports in the server because they are not intended for use in a production environment. Opening a port in your server is just as bad as opening a door for hackers to snoop through.

How to use Xdebug for PHP function debugging? How to use Xdebug for PHP function debugging? Apr 17, 2024 am 11:12 AM

By installing the XdebugPHP extension and enabling it, you can debug PHP functions using an Xdebug client such as PhpStorm or VSCode. Set breakpoints, run scripts using the IDE, enter debug mode to inspect variables, perform step-by-step debugging and view call stacks. In a practical case, you can set breakpoints on the sum function and use the debugger to view variables and execution flow to debug errors or optimize the code.

Code debugging methods for PHP functions Code debugging methods for PHP functions Apr 10, 2024 am 11:39 AM

Code debugging methods for PHP functions include: Built-in debugger: Use var_dump() or print_r() to output the contents of a variable or array. Logging: Use the error_log() function to record debugging messages to the specified file or system log. Breakpoint: Pause the program at a specific point in the code to examine variable values ​​and execution flow. Exception handling: Use try-catch blocks to handle exceptions thrown in functions and print exception messages and stack traces. Xdebug Debugger: Provides advanced debugging features such as tracking variable values, setting breakpoints and analyzing code coverage.

Debugging library in PHP8.0: Xdebug Debugging library in PHP8.0: Xdebug May 14, 2023 am 08:09 AM

Debugging is an inevitable part of PHP development. In order to help developers debug their own code more easily, PHP8.0 introduced a very useful tool in its debugging library: Xdebug. This article will introduce some of the main features of Xdebug and how to use it to simplify the process of PHP debugging. Xdebug is an open source debugging tool that can capture errors in PHP applications and provide detailed error stack trace information, as well as the variables being used. It helps developers detect and troubleshoot code

Using Xdebug debugging technology in ThinkPHP6 Using Xdebug debugging technology in ThinkPHP6 Jun 20, 2023 pm 09:14 PM

ThinkPHP6 is a popular PHP framework that uses a variety of technologies to make development more convenient. One such technology is debugging tools such as Xdebug. In this article, we will explore how to use Xdebug for debugging in ThinkPHP6. Install and configure Xdebug Before you start using Xdebug, you first need to install and enable it. In the php.ini file, you can add the following configuration: [xdebug]zend_extension=x

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Best Practices for PHP Code Refactoring Best Practices for PHP Code Refactoring May 06, 2024 pm 05:09 PM

Answer: PHP code refactoring follows the principles of improving decoupling, readability, maintainability, and reducing complexity. Practice: Use namespaces to organize code. Decouple components with dependency injection containers. Refactor redundant code. Decompose large classes. Use modern coding style.

Development tools in PHP Development tools in PHP May 23, 2023 am 08:18 AM

PHP is a programming language widely used in web development. For PHP development tools, choosing a suitable tool can make the developer's work more efficient and convenient. In this article, we will discuss several common PHP development tools, including integrated development environments (IDEs), text editors, and debugging tools. 1. Integrated development environment (IDE) PhpStorm PhpStorm is a powerful PHP development environment developed by JetBrains. It not only supports PH

See all articles