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
Apache Web ServerPHP

Avatar of undefined
Last Comment
Camillia
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Camillia
Camillia
Flag of United States of America image

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.
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

works now. I had localhost:88 in php.ini. I should only have localhost.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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.
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

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.
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

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.
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Thanks for the points and thanks for using EE, ~Ray
Avatar of Camillia
Camillia
Flag of United States of America image

ASKER

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.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo