Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
305 views
in Technique[技术] by (71.8m points)

PHPStorm + XDebug Setup Walkthrough

Up until recently, I've been writing code in PHP (via Notepad++) and debugging by checking the logs in IIS (gotta love that web-platform installer); I've since decided to update to a more efficient code-writing / testing environment, and after playing around for several moments with PHPStorm, decided to purchase it and give it a try. Since then, I have realized that in so far as tutorials and walk-throughs are concerned, PHPStorm is coming up a little short. Having given the manual a glance (RTFM, I know), and come up wanting, I'd like to ask if anyone out there would like to hand hold me through setting up PHPStorm with XDebug so I can stop hating myself for not studying the underlying systems well enough, and get back to coding.

TLDR; Could someone post a detailed walk-through for setting up PHPStorm + XDebug? Assume maximum level of stupidity on my part (I"m usually more than capable in the ASP.NET world, but I am approaching the intelligence level usually associated with some forms of sea-faring sponge in the PHP world).

The environment is Windows 7 Ultimate (64-bit) with IIS & PHP installed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I've found a more modern and easier solution partially based on CrasyCoder's post. The steps you need to do are the following:

  1. If your brand new php installation doesn't contain php.ini, rename the php.ini-development to php.ini
  2. Install xdebug with help of the wizard: http://xdebug.org/wizard.php Follow its recommendations literally.
  3. Put in your php.ini the string: xdebug.remote_enable=1
  4. Go to PhpStorm's settings: settings->php. Select or reselect directory containing php. Make sure you see 'Debugger: Xdebug x.x.x' string (where x.x.x stands for installed version)
  5. Install an extension for your favorite browser from here: http://xdebug.org/docs/remote
  6. From the main menu (not the settings window) go to 'Run->Edit configurations' and add new 'PHP Built-in Web Server' configuration. Point the 'Document root' to your project's directory. Note the port number.
  7. Chrome browser: enable the extension pressing on the little bug in the rightmost side of the omnibox and selecting the Debug option. Other browsers' extensions should work similarly.
  8. In PhpStorm's menu enable the 'Run -> Start Listen for PHP Debug connections' option.
  9. Set a breakpoint in your code in PhpStorm.
  10. Run (not debug) the configuration you created in step 6.
  11. In your browser go to localhost:port where 'port' is the port from step 6. Your PhpStorm should stop on the breakpoint and you can start squashing bugs in your code.

Considering that:

Steps 1-5 are made once per php installation.
Step 6 is made once per PhpStorm project.
Steps 7-8 are made once per debuggin session.
Steps 9-11 are made each program run.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...