博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ero-configuration Web Application Debugging with Xdebug and PhpStorm
阅读量:5040 次
发布时间:2019-06-12

本文共 3485 字,大约阅读时间需要 11 分钟。

1. Install Xdebug

To use Xdebug with PhpStorm for debugging PHP applications, you need to have a PHP development environment configured with Xdebug extension installed. This task is beyond PhpStorm’s control. More information on configuring PHP development environment can be found in .

Make sure that you have Xdebug installed properly. Please note that your Xdebug version should fit the PHP version you have (mind the PHP version number and thread-safe/non-thread-safe option) and installed as zend_extension. Don’t forget to set the xdebug.remote_enable setting to 1 in php.ini file. Detailed information on installing and configuring Xdebug can be found . You can download the latest version of the Xdebug plugin at its . Recommended stable versions are 2.2.1 or 2.1.3.

You can check the configuration by executing php --version in the terminal

Alternatively, execute a page with phpinfo(); PHP function and make sure that you have Xdebug extension enabled. The xdebug section of the document with the installed version should be available.

2. Prepare PhpStorm

Toggle the “Start Listening for PHP Debug Connections” button. Don’t use any run configurations.

Once you've installed and configured Xdebug, you can use the  tool to confirm that the configuration of Xdebug and PhpStorm are compatible. 

3. Set a breakpoint in the source code

Apart from setting the breakpoint manually, you can use the option Run | Break at first line in PHP scripts to have an automatic breakpoint at the first line of every PHP script you debug.

4. Activate debugger on server

In order to activate the debugger, you need to set a special GET/POST or COOKIE parameter (). You can do it manually, but it is much more convenient to use one a special tool such as  or bookmarklet for that.

Try our  and get bookmarklets which will work in any modern browser and allow you to start/stop a debugging session by controlling the Xdebug cookie.

 How to add "Start/Stop Debugging" bookmarklets to your browser bookmarks toolbar

5. Start a debug session in browser

6. Reload the current page

7. Set initial path mappings

Switch to PhpStorm; you'll see the Incoming Connection From Xdebug dialogue. You'll now need to select the path mappings so that PhpStorm can map the remote files on the web server to the local files in your project. If you have a deployment configured, then PhpStorm will offer to configure the mappings based on the paths you've already set in that deployment.

If you have no deployment configured (or if the file mappings in the deployment are different), then you can select a manual file to use for this incoming debugger session.

8. Debug!

After reaching the breakpoint the debugger is suspended. Now let’s investigate the application.

Troubleshooting

The first thing to check is that the Xdebug configuration is compatible with PhpStorm's configuration, you can do that using the  tutorial.

In some cases you may get the error message “Remote file path ‘path/to/script/on/the/server.php’ is not mapped to any file path in project“ or “The script ‘path/to/script/on/the/server.php’ is outside the project.” This means that PhpStorm is not sure which local file corresponds to the specified remote file path.

You can solve this problem quickly. Just set up the necessary path mappings by clicking the relevant link.

 

参考:https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

转载于:https://www.cnblogs.com/wawahaha/p/5170446.html

你可能感兴趣的文章
[51nod1267]4个数和为0(预处理+双指针)
查看>>
[poj2151]Check the difficulty of problems概率dp
查看>>
深入浅出之Smarty模板引擎工作机制(一)
查看>>
UE4物理动画使用
查看>>
线程间操作无效: 从不是创建控件“listBox1”的线程访问它
查看>>
2014.09.11 cURL
查看>>
Jython概要
查看>>
文件(图片)转base64
查看>>
剑指 offer set 2 从头到尾打印链表
查看>>
博客开通第69天
查看>>
博客开通第九天
查看>>
Java7/8 中的 HashMap 和 ConcurrentHashMap 全解析
查看>>
8086中的七种寻址方式
查看>>
秒杀系统解决方案
查看>>
Java动态代理机制
查看>>
【Git】Git工具常用命令
查看>>
ipmsg 绑定tcp错误
查看>>
九型人格判定
查看>>
NOPI读取模板导出(Excel中追加数据)
查看>>
linux mail 命令参数
查看>>