Ero-configuration Web application debugging with Xdebug and Phpstorm

Source: Internet
Author: User
Tags php development environment

1. Install Xdebug

To use Xdebug with Phpstorm for debugging PHP applications, you need to has a PHP development environment configured with Xdebug extension installed. This task is beyond Phpstorm ' s control. More information on configuring PHP development environment can is found in our web help.

Make sure so you have Xdebug installed properly. Please note that your Xdebug version should fit the PHP version has (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 is found here. You can download the latest version of the Xdebug plugin in its official website. Recommended Stable versions is 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. Xdebug extension enabled. The Xdebug section of the document with the installed version should is 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 Validating Your Debugging Configuration tool to confirm that The configuration of Xdebug and Phpstorm is 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 a automatic breakpoint at the first line of every PHP script debug.

4. Activate Debugger on server

In order to activate the debugger, you need to set a special get/post or cookies parameter (click here for details). You can does it manually, but it's much more convenient to use one a special tool such as browser toolbar or bookmarklet fo R that.

Try our Phpstorm bookmarklets generator and get bookmarklets which would work on any modern browser and allow your 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, Phpstorm can map the remote files on the Web server to the local files In your project. If you had a deployment configured, then Phpstorm would offer to configure the mappings based on the paths you ' ve already Set in that deployment.

If you had no deployment configured (or if the file mappings in the deployment is different), then you can select a Manu Al file to 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 are that the Xdebug configuration are compatible with Phpstorm's configuration, you can do that usi ng the Validating Your debugging Configuration Tutorial.

In some cases get the error message "Remote file path ' path/to/script/on/the/server.php ' isn't mapped to any File path in Project"or" thescript ' path/to/script/on/the/server.php ' is outside the project. " This means, Phpstorm is not a 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.

Reference: Https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm

Ero-configuration Web application debugging with Xdebug and Phpstorm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.