2011-02-10

PHP, Xdebug and PhpStorm - working!

For a long time I have been waiting for a PHP debugger that works. Until now, that was only ever half the case.
  • Eclipse required me to set up overly complicated debug profiles
  • NetBeans was also going into that direction
  • MacGDBp always triggered and allowed to step through the code, but variable inspection is broken
PhpStorm had it's share of trouble as well, but yesterday I experienced a working debug session. Just like that, deep variable inspection and stepping through the code just worked. Today I looked into CLI debugging because Robert needed that for some complicated FLOW3 task. Also works, although it requires one step that should not be needed. Anyway, here we go.


Environment

I use PHP 5.3.3, Xdebug 2.2.0-DEV and PhpStorm 2.0 (build 103.78). All this should work with Xdebug 2.1.0 as well, though.

Debugging through the browser

In PhpStorm you need to configure nothing, really. For the sake of it, have a look at the settings in "PHP > Debug". Here are mine:


So far I have no setup in "PHP > Servers" and nothing in "PHP > Debug > Skipped paths". Also, no run configurations are set up so far, just make sure the IDE key is set up:


Then, install the PhpStorm debugging bookmarklets (or some other Xdebug trigger), tell PhpStorm to listen for incoming connections (click so it looks like ) and start a debug session using the IDE key you gave to PhpStorm as well. If all is well, a window should pop up:
Simply click Debug and off you go.

Debugging CLI scripts

For CLI scripts this "zero config" setup does not work (it does for MacGDBp, so, please fix it), thus you need to do some extra work. Create a server configuration in the settings:


And a debug configuration through "Run > Edit configurations":


Now start the debug session manually in PhpStorm ("Run > Debug...") and select the "Unnamed" debug configuration. PhpStorm should then open the debug panel and tell you it is waiting for an incoming connection. Now call your CLI script:
export XDEBUG_CONFIG="idekey=PHPSTORM"
some/script.php
Now PhpStorm should pick up your debug request and stop at the first line or breakpoint.

Some hints
  • If you happen to have code in an excluded directory, e.g. for autogenerated things, you can step through them, but will do so blindfold, as PhpStorm does not ignore those files.
  • Explore the options for watches and breakpoints, like conditions. Some powerful stuff is hidden there...
I hope this post helps you with debugging, feel free to leave comments with further tips and (hopefully) success stories.

48 comments:

Crag said...

Also, if you use the Xdebug plugin (for safari or Firefox) it gets easier. You can get both at xdebug.

jc said...

Thanks for the step by step description it was really helpful.

Mr. F said...

thank you, this worked!, i've been searching all over place for this, i'm using wamp 2.1 + firefox 4 + phpstorm 2.0.1. Thanks again.

K_Wasseem said...

Karsten, you can equally do it with Netbeans just as fine :)
I will try to write one for netbeans/xdebug, I will hit you up with it..

Cheers!
//Wasseem

Tyler Style said...

I came across this post while looking for info on troubleshooting xdebug profiling. I've put up a (much more detailed) tutorial on using PhpStorm with a LAMP server and Ubuntu client myself, so I thought I'd link to it here as it might help future visitors with troubleshooting their setup.

clod said...

I like to use Codelobster PHP Edition for it.

Tùng Lê said...

can you explain this step:
Now call your CLI script:
export XDEBUG_CONFIG="idekey=PHPSTORM"
some/script.php

jowdjbrown said...

In all honesty this was one of my favourite blog posts that I have ever come across, please carry on blogging, you are a true asset to the blogging community.LKW chiptuning

Mickey James said...

They did a great job in repairing the ZehnBesten AC in my Excursion, Great Service, and Detailed explanation of what was done to my AC. I highly recommend them. Exceptional service and extremely honest. My AC was repaired at minimal cost and I saw firsthand why their reviews are perfect. I would highly recommend this company for your auto repair.

Tanika Co Valda said...

I have read your blog its very attractive and impressive. I like it your blog.

PHP 7 Training in chennai | PHP 7 Training Course

PHP 7 Training in chennai | Online PHP 7 Course

sheela said...

Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
Best Devops online Training
Online DevOps Certification Course - Gangboard

sasitamil said...


It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.

Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
Selenium training in bangalore

cathryn leno said...

This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
python training Course in chennai
python training in Bangalore
Python training institute in bangalore

Unknown said...

The article is so informative. This is more helpful for our
software testing training in chennai
selenium online training Thanks for sharing

Madhu Balan said...

Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
Java Training in Chennai
Java Training in Coimbatore
Java Training in Bangalore

vinudevan said...

Thanks for sharing informative article with us...
Hibernate Training in Chennai
Hibernate course in Chennai
Hibernate Training institute in Chennai
hibernate training in T nagar
hibernate training in Guindy
Spring Training in Chennai
clinical sas training in chennai
DOT NET Training in Chennai
QTP Training in Chennai
LoadRunner Training in Chennai

Riya Raj said...

Wonderful blog!!! Thanks for sharing this great information with us...
SEO Training in Chennai
SEO Course in Chennai
SEO Training Institute in Chennai
SEO institute in Chennai
SEO training in Tnagar
SEO training in Thiruvanmiyur
Big data training in chennai
Software testing training in chennai
Selenium Training in Chennai
JAVA Training in Chennai

Anbarasan14 said...

Nice useful information. Thanks for spending your valuable time to share thanks blog with us.
Spoken English Class in Anna Nagar
Spoken English Class in Porur
Spoken English Class in T Nagar
Spoken English Class in Adyar
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching Centre in Chennai
English Speaking Classes in Mumbai
IELTS Classes in Mumbai

gowsika said...

Thanks For Sharing!Wonderful blog & good post.Its really helpful for me, waiting for a more new post.
Air hostess training in Bangalore
Aviation courses in Bangalore
Airport Management Courses in Bangalore
Ground staff training in Bangalore
Aviation Academy in Chennai
Aviation Academy in Chennai
Air hostess Training in Chennai
Air hostess Training in chennai
Aviation Academy in Chennai
Aviation Courses in Bangalore

Rahuldevan said...

Thanks for giving excellent Message...Waiting for the next article...
Html5 Training in Chennai
Html5 Course
Html5 Training Course
Html5 Training in Tnagar
html5 training in vadapalani
DOT NET Training in Chennai
core java training in chennai
Hibernate Training in Chennai
Mobile Testing Training in Chennai
SAS Training in Chennai

Aruna Ram said...

Excellent blog, I read your great blog and it is one of the best explanation about this content. Keep doing the new posts...


Pega Training in Chennai
Pega Course
Primavera Training in Chennai
Tableau Training in Chennai
Unix Training in Chennai
Job Openings in Chennai
Placement Training in Chennai
Linux Training in Chennai
JMeter Training in Chennai
Pega Training in T Nagar
Pega Training in Anna Nagar

manjuragul said...

I have to agree with everything in this post. Thanks for the useful sharing information.
Selenium Training in anna nagar
selenium Training in Chennai
selenium Training in OMR
DevOps Training in OMR
Web Designing Course in anna nagar
selenium Training in T Nagar
Android Training in T Nagar
ccna Training in OMR

Sadhana Rathore said...

Excellent post, I learned something new and challenging one in this task. Update more info.
Web Designing Course in chennai
web designing training in chennai
Web Development courses in Chennai
AngularJS Training in Chennai
PHP Training in Chennai
gst Training in Chennai
ReactJS Training in Chennai
Web Designing Course in Velachery
Web Designing Course in T Nagar
Web Designing Course in OMR

silakarim said...

Thanks for sharing this post. It is very helpful for me to develop my skills in a right way.
Ethical Hacking Course in Velachery
Ethical Hacking Course in T Nagar
Ethical Hacking Course in Tambaram
Ethical Hacking Course in Anna Nagar
Ethical Hacking Course in Porur
Ethical Hacking Course in Vadapalani
Ethical Hacking Course in Thiruvanmiyur
Ethical Hacking Course in Adyar
Ethical Hacking Course in OMR

Aruna Ram said...

Surpassing Article, This post contains great information about this topic. Can you please do a more extra post like from this blog and Thank you much more for sharing this useful info.

Primavera Training in Chennai
Primavera Coaching in Chennai
Corporate Training in Chennai
Pega Training in Chennai
Embedded System Course Chennai
Linux Training in Chennai
Job Openings in Chennai
Social Media Marketing Courses in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Primavera Training in Anna Nagar

charmidevan said...

valuable blog thanks for sharing it...waiting for next update...
Mobile Testing Training in Chennai
Mobile App Testing Training
Mobile Testing training in vadapalani
Mobile Testing training in Guindy
Mobile Testing training in Thiruvanmiyur
Manual Testing Training in Chennai
LoadRunner Training in Chennai
Photoshop Classes in Chennai
Spring Training in Chennai
QTP Training in Chennai

Riya Raj said...

More impresiive Blog!!! Its more useful for us...Thanks for sharing with us...
Hadoop Training in Chennai
Big data training in chennai
Big Data Course in Chennai
hadoop training
Hadoop training in porur
Big data training in OMR
Android Training in Chennai
IOS Training in Chennai
JAVA Training in Chennai
Selenium Training in Chennai

lokeshivam said...

Well written Blog, I really enjoy reading your blog. this info will be helpful for me. Thanks for sharing.
Data Science Course in Chennai
Data Science Classes in Chennai
Data Science Training in Chennai
Machine Learning Training in Chennai
Blue Prism Training in Chennai
UiPath Training in Chennai
Automation Anywhere Training in Chennai
Data Science Training in Anna Nagar
Data Science Training in T Nagar
Data Science Training in OMR

tech updates said...

nice blog

machine learning training in bangalore

data science training in bangalore

big data and hadoop training in bangalore

Tech Guy said...

Nice article.
For Python training in bangalore, visit:
Python training in bangalore

tech updates said...

VISIT HERE => DEVOPS TRAINING IN BANGALORE

Tech Guy said...

For Data Science training in Bangalore, Visit:
Data Science training in Bangalore

virgoacp said...

Awesome post. I am a normal visitor of your blog and appreciate you taking the time to maintain the excellent site. I’ll be a frequent visitor for a long time.

ACP Sheet
ACP Sheet Price
Aluminium Composite Panel

Techy said...

Nice post
For Data Science training in Bangalore
Visit:
Data Science training in Bangalore

Updated Tech News said...

For IOT Training in Bangalore Visit:
IOT Training in Bangalore

Anonymous said...

nice blog
training and placement institute in Bhopal -:VSIPL

best digital marketing and web devleopment company in Bhopal -: seo network point

yathish said...

The great information that you shared. It will help all of them. Thanks for posting. Keep maintain the updates
PHP Development Company
|
ERP Solution
|
magento ecommerce
|

yathish said...

Good information that you shared. Thanks for posting such a wonderful posting.The great information that you shared. It will help all of them. Thanks for posting. Keep maintain the updates
PHP Development Company
|
Ecommerce Solution Provider
|
Data Extraction Solutions
|

Customer relationship management said...

This is really an awesome post, thanks for it. Keep adding more information to this.selenium training in bangalore

Customer relationship management said...

Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.coded ui training in bangalore

Customer relationship management said...

Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving.big data testing training in bangalore

Customer relationship management said...

Linking is very useful thing.you have really helped lots of people who visit blog and provide them use full information.mobile application testing training in bangalore

Customer relationship management said...

Your articles really impressed for me,because of all information so nice.manual testing training in bangalore

watson said...

Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledge.web designing training in bangalore

watson said...


Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts.web designing training in bangalore

vijay said...

Thanks for your valuable post... The data which you have shared is more informative for us...
aws Training in Bangalore
python Training in Bangalore
hadoop Training in Bangalore
angular js Training in Bangalore
bigdata analytics Training in Bangalore

Softgen Infotech said...

Wonderful thanks for sharing an amazing idea. keep it...

Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also it provides placement assistance service in Bangalore for IT.

Softgen Infotech said...

Really i appreciate the effort you made to share the knowledge. The topic here i found was really effective...

Start your journey with SAP S4 HANA Simple Logistics Training in Bangalore and get hands-on Experience with 100% Placement assistance from experts Trainers @Softgen Infotech Located in BTM Layout Bangalore. Expert Trainers with 8+ Years of experience, Free Demo Classes Conducted.