一文浅析PHPStorm怎么配置XDebug远程调试PHP代码
PHPStorm怎么通过配置 XDebug 调试本地代码或远程调试服务器上的 PHP 代码?下面本篇文章就来带大家了解一下配置方法,希望对大家有所帮助!
1、PHP 配置
为 PHP 安装 xdebug, 方法略
配置文件 php.ini
[XDebug]zend_extension = "/opt/lampp/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so";开启自动跟踪xdebug.auto_trace = 1;开启异常跟踪xdebug.show_exception_trace = 0;开启远程调试自动启动xdebug.remote_autostart = 1;开启远程调试xdebug.remote_enable = 1xdebug.remote_connect_back = 1xdebug.max_nesting_level = 250;收集变量xdebug.collect_vars = 1;收集返回值xdebug.collect_return = 1;收集参数xdebug.collect_params = 1xdebug.trace_output_dir = "/opt/lampp/tmp"xdebug.profiler_append = 0xdebug.profiler_enable = 1xdebug.profiler_enable_trigger = 0xdebug.profiler_output_dir = "/opt/lampp/tmp"xdebug.profiler_output_name = "cachegrind.out.%t-%s"xdebug.idekey=PHPSTORMxdebug.remote_handler = "dbgp"xdebug.remote_host = localhostxdebug.remote_port = 9000复制代码
2、phpstorm 配置
File>Settings>Languages&Frameworks>PHP>Servers
添加一个 Server(设置 Web 服务器的Host、Port 等信息)
注意:
要想调试远程服务器上的代码,需要使用 use path mappings:
如果远程服务器与本机不在同一个路由器下,例如本机为 10.117.123.122(隶属于路由器 A),远程服务器为 192.168.123.100(隶属于路由器 B)。这时候想用 Xdebug 进行调试,就需要配置本机 IDE 所在的路由器的端口映射,将 9000 映射到本机。
File>Settings>Languages&Frameworks>PHP>Debug
看到 XDebug 选项卡,port 填9000,其他默认。
File>Settings>Languages&Frameworks>PHP>Debug>DBGp Proxy
IDE key 填 PhpStorm (host 填 localhost,port 填 9000)
Run>Edit Configurations
添加 Web 调试服务器
启动监听
在phpstorm中设置断点后,启动监听,就是电话一样的图标。用 chrome 浏览 localhost 中的指定断点的文件,会自动进入断点,在 phpstorm 中看到调试信息。
如果执行完上述步骤后,还不行。确认下本机的防火墙是否开放对应端口(或者直接关闭本机防火墙)
推荐学习:《phpstorm使用教程》

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



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.

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

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.

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

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.

Inventory of essential tools for PHP development: Mastering these three integrated development tools requires specific code examples. With the rapid development of the Internet, PHP, as a programming language widely used to develop websites and web applications, has attracted more and more developers. love. In order to improve development efficiency and quality, it is essential to use appropriate integrated development tools. In this article, we will take stock of the three necessary tools for PHP development and provide specific code examples for each tool to help developers better master and apply them. The first tool: PHPSt

Revealing the Secrets of PHP Integrated Development Tools: List of 3 Common Tools, Need Specific Code Examples With the continuous development of the Internet, PHP, as a scripting language for developing Web applications, is widely used in various fields. In order to improve development efficiency and code quality, many programmers choose to use integrated development tools (Integrated Development Environment, referred to as IDE) for PHP development. This article will reveal the three common PHP integrated development tools and provide specific

PHP is a popular server-side scripting language that is widely used for web development. In order to write efficient and streamlined PHP code, programmers need to use an excellent code editor. This article will introduce some common code editors in PHP programming. SublimeTextSublimeText is probably one of the most popular code editors. Its flexibility and ease of use make it the editor of choice for many developers. Key features of SublimeText include: High degree of customization
