Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Debugging PHP code

I have WAMP, NetBeans and phpMySQL. I want to debug the code in netbeans on my local machine.

I click the debug button, page comes up with this URL

http://localhost:88/BDTestProject/index.html?XDEBUG_SESSION_START=netbeans-xdebug

But I get a msg at the bottom of netBeans "waiting for connection..". Debugger doesnt stop at the debug lines...
I found this link and I get the pop-up msg at the end of this link when I stop the debugger.
http://martinsikora.com/debugging-php-in-netbeans-using-xdebug

There's a script that the link says to run to open port 9000 but that link isnt found.

I followed the steps in that link. I've attached a screenshot. Any other ideas why the debugger doesnt stop at debug lines? What is that script that should be run?

This is in my PHP.ini. I've attached my screenshots as well.

I even tried this
http://arturito.net/2011/05/21/local-and-remote-php-debuging-in-netbeans-with-xdebug-on-google-chrome-just-like-in-visual-studio/

and this

https://www.jetbrains.com/phpstorm/webhelp/configuring-xdebug.html


; XDEBUG Extension

zend_extension = "c:/wamp/bin/php/php5.4.3/zend_ext/php_xdebug-2.2.0-5.4-vc9-x86_64.dll"

[xdebug]
xdebug.remote_enable = on
xdebug.profiler_handler = dbgp
xdebug.remote_host = localhost:88
xdebug.profiler_host = localhost:88
xdebug.profiler_port = 9000
xdebug.profiler_enable = on
xdebug.profiler_enable_trigger = on
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"

Open in new window

Doc1.docx
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

I totally understand what you're saying. I'm setting up my environment and wanted to step thru the code and that's how I came across xDebug...

You know what was wrong with that phpMySQL question I had and why I couldnt understand how it connects to the database? The orig developer has admin's userid/pwd harcoded in the code and just gives access to the admin user without any database hits, any validation. I .Net, I use Membership which hits the database for userid/pwd validation..

I'm creating test PHP code..using echo and watching tuotrials. Been reading about xDebug and that it's not easy thing to set up. I'll take a look at those books you've listed.
works now. I had localhost:88 in php.ini. I should only have localhost.
Glad to see it's getting pointed in the right direction!

On the subject of "stepping through the code," I totally get it.  A couple of years ago I had a development project on a server that was misconfigured -- it could not produce any error messages.  A PHP parse error equaled a white screen.  Even a PHP message equaled a white screen.  So any error, no matter how trivial, caused a trip back to the drawing board.  My response was to write my code in tiny bits, one or two lines at a time.  To my utter amazement, I found myself to be an order of magnitude more productive when measured by lines of executable code over time.  What I had never realized before that exercise was that I spent much more time debugging than I spent coding.  And when I changed my work habits so that I was going forward in baby steps, I found that I almost never had to debug anything.

So today my creative process is underpinned by (1) good test cases and (2) lots of data visualization and (3) step-wise incremental development.
Good advice. I like #3....
Well, this is weird. I have 2 projects. One has one file "index.php" with one line of code. I can debug that (this wasnt working but now it works)...

 The other one, nope, still cant debug it! Same error as before for the larger project. I inherited this code. I wonder if I should create a new project and add files back to it, one by one. Dont know.
I added a new php page to the project with 2 lines
echo 'test1';
echo 'test2'

Made the new page as the default and xDebug stops and the debug works.

I'll open another question for this. It's weird.
Thanks for the points and thanks for using EE, ~Ray
Figured it out just in case someone has the same issue. I added debug extension for Chrome. It adds a debug addon on top. I brought up the page and that add-on is disabled. I click it to enable it (turns green) and that's when the debugger stops at breakpoints.