How do you debug PHP scripts?
I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful.
What is the best (in terms of fast and easy) way to debug in phpStorm or any other IDE?
How do you debug PHP scripts?
I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful.
What is the best (in terms of fast and easy) way to debug in phpStorm or any other IDE?
Try Eclipse PDT to setup an Eclipse environment that has debugging features like you mentioned. The ability to step into the code is a much better way to debug then the old method of var_dump and print at various points to see where your flow goes wrong. When all else fails though and all I have is SSH and vim I still
var_dump()
/die()
to find where the code goes south.Output buffering is very useful if you don't want to mess up your output. I do this in a one-liner which I can comment/uncomment at will
There are many PHP debugging techniques that can save you countless hours when coding. An effective but basic debugging technique is to simply turn on error reporting. Another slightly more advanced technique involves using print statements, which can help pinpoint more elusive bugs by displaying what is actually going onto the screen. PHPeclipse is an Eclipse plug-in that can highlight common syntax errors and can be used in conjunction with a debugger to set breakpoints.
and also used
+1 for print_r(). Use it to dump out the contents of an object or variable. To make it more readable, do it with a pre tag so you don't need to view source.
Also var_dump($thing) - this is very useful to see the type of subthings
I often use CakePHP when Rails isn't possible. To debug errors I usually find the
error.log
in the tmp folder and tail it in the terminal with the command...It give's you running dialog from cake of what is going on, which is pretty handy, if you want to output something to it mid code you can use.
This can usually give you a good idea of what is going on/wrong.
Nusphere is also a good debugger for php nusphere