Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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 our web help.

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 here. You can download the latest version of the Xdebug plugin at its official website. Recommended stable versions are 2.2.1 or 2.1.3.

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

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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.

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

2. Prepare PhpStorm

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

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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

3. Set a breakpoint in the source code

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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 (click here for details). You can do it manually, but it is much more convenient to use one a special tool such as browser toolbar or bookmarklet for that.

Try our PhpStorm bookmarklets generator 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

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

6. Reload the current page

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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.

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

8. Debug!

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

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

Troubleshooting

The first thing to check is that the Xdebug configuration is compatible with PhpStorm's configuration, you can do that using the Validating Your Debugging Configuration 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.

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

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

Zero-configuration Web Application Debugging with Xdebug and PhpStorm

来源: Zero-configuration Web Application Debugging with Xdebug and PhpStorm - PhpStorm - Confluence

weinxin
我的微信
一个码农、工程狮、集能量和智慧于一身的、DIY高手、小伙伴er很多的、80后奶爸。
Igor
  • 版权声明: 发表于 2018-11-1618:17:52
  • 转载注明:http://blog.tsingmac.com/prolions/servertech/webserver/wordpress/368/
wordpress怎么手动自定义文章显示数量 Wordpress

wordpress怎么手动自定义文章显示数量

  下面给大家介绍wordpress手动自定义文章显示数量的方法详解,希望对需要的朋友有所帮助! WordPress每页显示的文章数在后台阅读设置中指定,会应用到blog列表页(通常是首页)...
ErphpDown V11.4安装配置教程 Wordpress

ErphpDown V11.4安装配置教程

Erphpdown是一款集会员管理、支付管理、推广管理于一体的Wordpress插件,目前ErphpDown的最新版本是ErphpDown V11.4,那么今天我来讲解一下ErphpDown v11....
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: