Hello all,

I've been working for awhile building a web with PHP. So far, so good. But I'm finding refactoring to be frustrating, because I haven't found a tool that will give a full syntax check across my code. Yes, there is the "php -l" command to do the lint-style check, but that's a very basic check. I'm thinking of a case where I define

function foo() {
   ...
}

in one file and then call foo() from another file. In the course of refactoring, I change "foo()" to "betterName()". In a compiled language, any reference to foo() that I missed changing would cause a compilation error. Since PHP is interpreted, I only see an error when I load a page that hits the specific line of code with the error. Thus, it's easy to miss an error.

So the question: does anyone know of a tool that will do a real syntax check, even to the level of making sure called functions are actually defined? I've been looking for a while, but I haven't been able to find anything.

Thanks,

Dave.

php designer does a good job with debugging. Like php, its free to download. It has a code coloring scheme similar to dreamweavers that will help you spot syntax errors and the debug will find errors and tell you what line the error is found on.

php designer does a good job with debugging. Like php, its free to download. It has a code coloring scheme similar to dreamweavers that will help you spot syntax errors and the debug will find errors and tell you what line the error is found on.

Thanks for the quick response. I just took a look at phpDesigner's web site. It has a free trial version, good for 14 days, then it's 39 euro for one license.

Unfortunately, it doesn't run on Mac, so I won't be able to try it out until I get home. (I do most of my work on a Mac laptop.) Since I can't run it, I just took a look at the web site. I see that it does syntax checking, but it looks like it's just the basic syntax checking you can do from the command line with "php -l". I'm using the PHP plugin for Eclipse, which can also do that. I'm looking for a bit more.

a.php:

function foo() {
  echo '<p>This is foo()';
}

b.php:

require_once('a.php');

foo();

I point my browser at b.php, and I'll get some simple output. Now, suppose I edit a.php and change "foo()" to "bar()", but don't change b.php. When I point my browser to b.php, I'll get an undefined function error. I'm looking for a tool that will find that error without me having to view b.php in a browser (because presumably I have lots of pages, and the call might be within some if statements, and I don't want to have to execute every line of code I have to catch the error). Eclipse's plugin doesn't find it, the php command line tool doesn't find it, and looking at http://www.mpsoftware.dk/phpdesigner_features.php, it doesn't look like it will either (one listed feature says "Syntax check PHP using the PHP Interpreter").

I'm thinking of the work I've done in Java, C++, and other compiled languages. If I make a change like this, then the compiler will look at all my code and complain that it can't find foo(). It does the checking for me and gives a list of problems.

Sorry if this is redundant, just trying to be clear.

Thanks again,

Dave.

Probably the best debugging in PHP will be in Zend Studio (I use professional) which is cross-platform. There should be a free trial on their site. It does a pretty good job of picking apart your code like a crazy english teacher with a red pen.

Despite the high price tag, I do highly recommend it.

please use mozilla firefox and download firebug as add on and then install it.anytime there is error in the browser it track it for u

Probably the best debugging in PHP will be in Zend Studio (I use professional) which is cross-platform. There should be a free trial on their site. It does a pretty good job of picking apart your code like a crazy english teacher with a red pen.

Despite the high price tag, I do highly recommend it.

Thanks for the suggestion, sumwatt. I checked out Zend Studio, but unfortunately, it doesn't offer what I'm looking for either. Their code analyzer is pretty cool (and found some interesting screwups), but it doesn't check that a function you've called actually exists somewhere. In a project setting, it seems like it ought to be able to do that. Oh well.

please use mozilla firefox and download firebug as add on and then install it.anytime there is error in the browser it track it for u

I've been using Firebug for a while and it's a fantastic tool for figuring out problems with JavaScript, CSS, and other client side problems, but it doesn't address what I'm looking for in PHP.

please download PHP designer from www.phazeddl.com and use it. the software will indeed help in debugging PHP and i bet u will like bros

commented: Don't like to warez sites -1

phpDesigner's official site appears to be http://www.mpsoftware.dk/, so I would download it from there. Looking over their web site, I don't see anything that suggests they have the feature I'm looking for. However, since it's not the first time this tool's been suggested, I decided to just write to them and ask. I'll post the answer when I get it.

Dave.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.