PHP Syntax checking

Reply

Join Date: Dec 2007
Posts: 8
Reputation: dmc72 is an unknown quantity at this point 
Solved Threads: 0
dmc72's Avatar
dmc72 dmc72 is offline Offline
Newbie Poster

PHP Syntax checking

 
0
  #1
Dec 12th, 2007
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

  1. function foo() {
  2. ...
  3. }

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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: PHP Syntax checking

 
0
  #2
Dec 12th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 8
Reputation: dmc72 is an unknown quantity at this point 
Solved Threads: 0
dmc72's Avatar
dmc72 dmc72 is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #3
Dec 12th, 2007
Originally Posted by buddylee17 View Post
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:
  1. function foo() {
  2. echo '<p>This is foo()';
  3. }

b.php:
  1. require_once('a.php');
  2.  
  3. 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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1
Reputation: sumwatt is an unknown quantity at this point 
Solved Threads: 0
sumwatt sumwatt is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #4
Dec 13th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: ebencosoft is an unknown quantity at this point 
Solved Threads: 0
ebencosoft ebencosoft is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #5
Dec 14th, 2007
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
Last edited by ebencosoft; Dec 14th, 2007 at 5:24 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 8
Reputation: dmc72 is an unknown quantity at this point 
Solved Threads: 0
dmc72's Avatar
dmc72 dmc72 is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #6
Dec 18th, 2007
Originally Posted by sumwatt View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 8
Reputation: dmc72 is an unknown quantity at this point 
Solved Threads: 0
dmc72's Avatar
dmc72 dmc72 is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #7
Dec 18th, 2007
Originally Posted by ebencosoft View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 3
Reputation: ebencosoft is an unknown quantity at this point 
Solved Threads: 0
ebencosoft ebencosoft is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
-1
  #8
Dec 19th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 8
Reputation: dmc72 is an unknown quantity at this point 
Solved Threads: 0
dmc72's Avatar
dmc72 dmc72 is offline Offline
Newbie Poster

Re: PHP Syntax checking

 
0
  #9
Dec 19th, 2007
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC