Forum Moderators: coopster

Message Too Old, No Replies

Is there a tool to help debug php code?

Need a tool or add on to help debug php

         

nubbin

4:15 am on May 12, 2004 (gmt 0)

10+ Year Member



Hi,

Just learning php/mysql and have used it to set up things like a contact form on my web site. I have Dreamweaver MX but am hand coding the php code.

Is there a good free tool I could use to speed up debugging of php? I waste quite a bit of time debugging basic mistakes like missing periods or quote marks.

I like the Dreamweaver Validate HTML markup tool, I just wish it had a similar tool for PHP

Thanks all

ergophobe

4:05 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are a few things that can help.

- editor with syntax highighting and brace/paren matching. This iwll help with real obvious things like not closing a quoted string.

[webmasterworld.com...]
[webmasterworld.com...]

- there are also a variety of debuggers, most of which, in my experience, provide little additional information (in part because I just can't get most of them to run). Search google on
"php debuggers"
"php debuggers dbg"
"php debuggers xdebug"

and see what you get. I sort of got xdebug to work and many people seem to get dbg to work.

henry0

8:17 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not to forget :)
<?
error_reporting (E_ALL);
?>
also I question why almost no one mention
Quanta - Bundled - with RH 9 (previous RH version offers only a Quanta version that was in need of a bit of debugging)

I use it and it works fine

Henry

ergophobe

3:40 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The Quanta docs mention debugging PHP, but there's no information there. Have you tried it?

Tom

bcolflesh

3:42 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



PHPEdit has a fully functional debugger:

[phpedit.net...]

ergophobe

3:59 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My experience with PHPEdit was that not much was fully functional, let alone the debugger ;-)

Maybe I was just too stupid to get it to run or maybe it's been improved.

bcolflesh

4:25 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe I was just too stupid to get it to run or maybe it's been improved.

Weird - always worked perfect for me...

henry0

5:06 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Quanta
Hmmm! good question I use it intensively but did not use the debug
as a matter of fact I am starting a new project.. will report later
one item I like is that Quanta very well check for you any span of multiple
{
{
{
}
}
}

Henry

jatar_k

5:16 pm on May 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I am with ergophobe on phpedit, used it for a while to see if it would be worth using and it would constantly break.

The only thing that ever really worked was the uninstall and I enjoyed that feature immensely.

ergophobe

6:21 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It seems that I install phpedit every year or so, find lots more buggy features added, the old bugs still present, and then uninstall.

I have found a few editors that are much less ambitious, but at least get things working before moving on to the next thing. That said, if I could ever get the phpEdit/dbg debugger working, I would consider using it.

coopster

6:33 pm on May 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



ergophobe, I've seen you refer to hapedit [hapedit.free.fr]. Out of curiousity I downloaded a copy. It's pretty nifty. I don't see you commenting about it here though. Have your feelings changed?

jatar_k

6:59 pm on May 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I used hapedit for a while but never really got into it, it was quite a while ago now though.

With all these editors out there I have never gotten away from textpad.

ergophobe

7:16 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I didn't mention hapedit because it doesn't have a debugger.

Also, I've sent in so many feature requests, bug reports and corrected translations the interface, etc., that I'm starting to feel like I need a disclaimer when I recommend it (by which I mean a disclaimer saying that I feel "connected" not a disclaimer saying I don't recommend it - it's the least buggy freeware editor I've found that has syntax highlighting).

It works for me and it's my favorite, but I've also tried and liked context, xored, kommodo, and others. Mostly anything that's relatively bug free and relatively small, with line numbering and preferably syntax highlighting is okay by me.

[edited by: ergophobe at 9:22 pm (utc) on May 13, 2004]

henry0

7:18 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Quanta Debug
<<<
as per quanta "Sorry, nothing yet"
>>>

ginga

11:20 pm on May 13, 2004 (gmt 0)

10+ Year Member



homesite and var_dump :-)

Timotheos

10:01 pm on May 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Stumbled accross this PHP to C++ translator [mibsoftware.com] and thought it an interesting concept for debugging.

corz

11:54 pm on May 14, 2004 (gmt 0)

10+ Year Member



something simple and effective, I find it useful..

<?php
/*
the debug unit (aka. "du")

a simple debug function, outputs stuff to a file

the *concept* of this is much more important than the code

once you get serious about a project, you need to get information.
a wee debug system can save you a lot of trouble. you can have your
debug information just there, rather than echoing $hite all over your
page, which people do, and I used to, too.

any good text editor will update when files do (BBEdit, TextPad, etc)
this made tuning corzoogle's scoring mechanisms a great deal easier.
sometimes I had the readout in a tab of my web browser

call

debug(out)

to finalise (and output) the debug information to the .out file
you can do this at any point, and any number of times, useful if
you need to check a value before or during some long operation.

notes..
the // :debug:comments allow you to remove ALL debug lines at once
(with a decent text editor, or grep)

I also find it useful to keep my debug lines hard-left regardless of the
current indentation.

all the scripts in my php test folder use the same debug.out file
there's one in this source folder, where I work on these scripts, try it.

*/

//examples..
debug("\nstarting debug output for du.php..\n");// :debug:

/* //:debug:
// get all the server variables.. //:debug:
while (list($key, $val) = each($_SERVER)) { //:debug:
debug($key.chr(9).$val."\n"); }//:debug:
debug("\n\n");//:debug:
*///:debug:

$string = 'colours';
$array = array('yellow','orange','green','blue');

debug('these are "'.$string.'"'."\n\n");// :debug:
debug(print_r($array, true)."\n");// :debug: - wont work @ my web host, needs >= php4.3
if(count($array) > 0) debug('number of colours? = '.count($array)."\n"); // :debug:

echo '<html><body><center>putting debug information here on the page is real nasty!<br>';
echo '<a href="debug.out" title="check out the info!">check this instead</a></center>
</body></html>';

/*
function:debug()
*/
function debug($data) {
global $debug_string; // make global too, if you like

if($data == 'out') {
$debug_string .= "\n\n";

if(file_exists('debug.out')) {
$debug_file = fopen('debug.out', 'w');
fputs($debug_file, $debug_string);
fclose($debug_file);
}
} else { $debug_string .= $data; }
}/*
end function debug()
*/

debug(out);// :debug://for something to read, you MUST end with this, or debug('out')
?>

hmm.. the code function seems dodgy here.

forgive the splurge, I would have posted a URL to this source, but TOS, you know..

;o)
(or

[edited by: jatar_k at 12:21 am (utc) on May 15, 2004]
[edit reason] removed url [/edit]

Cogs

5:07 pm on May 15, 2004 (gmt 0)



PHPEdit debugger is what I use, and it's pretty easy to install.

To get the debugger working you must go into preferences -> PHP Debugger -> CGI PHP executable

btw - The debugger is just something the PHPedit developers tacked on.

nubbin

10:16 am on May 19, 2004 (gmt 0)

10+ Year Member



Thanks for your replies. Seems like there isn't a clear consensus about the best way to debug PHP. That makes it a bit more time consuming for me to decide what to do... I was sort of hoping there would be a good plug in for dreamweaver to give help it do php debugging.
One simple thing I've started doing is using the code coloring in Dreamweaver...that helps with the basics like missing semicolons. It only works if you save the file as .php file. I was saving them as .html with php embedded, if you do that the php code coloring doesn't work properly.
I'm a bit reluctant to download any of the debuggers mentioned as none seem like clear winners and I know from experience I'm likely to waste a lot of time trying to get them to work...and by sounds of it they are all buggy.
Corz debug function looks interesting but not what I'd call simple as a newbie. The prospect of avoiding echoing stuff everywhere is very appealing so I'll try and work out what his reply means

Thanks once again

corz

9:09 pm on May 19, 2004 (gmt 0)

10+ Year Member



if you need a hand - really, all you do is tag the debug function onto the end of your code, and slam debug lines wherever you need information, finish with
debug(out);
- feel free to mail/stickymail me about this.

for actual coding, a decent text editor with proper syntax highlighting will go a long way towards helping you code more efficiently. if you have a mac, I recommend bbedit (bbedit is dreamweaver-savvy, and visa-versa), which has lots of real cute stuff I take for granted until I go to use a text editor on another platform, like the ability to double click any bracket and have it "balanced" - all the text inside the bracket becomes highlighted

saves me hours

;o)
(or

jatar_k

9:49 pm on May 19, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



bbedit is the only program to beat textpad, imho

absolutely love it

bcolflesh

1:20 pm on Jun 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just came across Xdebug:

[xdebug.org...]

Might be of use to someone who finds this thread.