
For me, coding in PHP has been a good news/bad news thing. The good news is that the language has a large development community, which brings to it a boat-load of tools and support sites. I also appreciate the existing applications and code base.
The bad news is that the actual writing of the code can get to be a chore. The PHP code-writing environments that I have used require a bit (sometimes a lot) of work to get up and running. Also, the "code assist" features in those tools are limited — not much more than auto-indentation and color coding to indicate keywords.
In short, none of the PHP IDEs that I have come across offer the power of the Visual Studio IDE to which I have become accustomed in my .NET coding activities. I always thought that it would be really cool if I could program in PHP under VS. Well, it seems that I can.
JCX Software promises that VS.PHP, its VS 2005 add-in, brings the power and versatility of the Visual Studio IDE to PHP coding. Among its advertised features are:
Intelli-Sense support for keyword selection, function selection, and code completion. Code outlining Support for PhpDoc within the Visual Studio IDE The ability to debug server side PHP code and client side Javascript code in the same session Runs under the PHP4 or PHP5 run-time engine Automatic deployment
With a list like that, I was interested. I took VS.PHP for a spin. First, I did some small demo work to see if the product did all it claimed. Then I ported an existing PHP project into VS.PHP — one that I was working on anyway — to really take the product to task. In this article, I'll tell you how it all worked out.
Working the IDE
VS.PHP really is about writing PHP code within the Visual Studio environment. Thus, everything that I knew how to use in VS.NET was readily available in VS.PHP. Adding new and existing items to a PHP project was no different than adding items to a C# or VB project. The class browser did a good job of showing me my classes, independent of file location. I could view a PHP class's methods and fields just as I would under a C# or VB project.
The code edit window is straight-ahead Visual Studio. If the file being edited has more than one class defined, you select the class from the top left drop-down. The right drop-down displays a list of the class's constructors and methods. The code window supports Intelli-Sense's display of a variable's options, and the standard PHP functions are listed when you strike Ctrl+Spacebar.
VS.PHP ships with a whole bunch of PHP libraries that you add to the Visual Studio PHP project as references. Once a reference is added, the libraries — such as one for MySQL support — are available for auto-select.
Also, VS.PHP supports code complete of object variables. But more about this later.
Runtime errors are reported using the PHP runtime engine. So, unlike a standard .NET project — where you get you a very detailed exception dump from the Common Language Runtime (CLR) — VS.PHP provides the standard PHP error dump into the Web page in which the error occurs. The PHP runtime reports the error's file and line location and a brief error message (best understood by experienced PHP developers).
Server Side Debugging
After the initial Hello World run, I put some break points in the PHP code. I had no problem examining a variable's value using QuickWatch and subsequently assigning a variable to a watch List.
VS.PHP provided a fully-functional Autos window. However, when I tried to go back into my code using the Visual Studio Set Next Statement from the cursor's context menu, I discovered that the feature seemed not to be supported. Thus, moving back in code was a problem.
Client Side Debugging
Just as I had done previously in the server side code, I set a breakpoint in client side Javascript that was in a JS file separate from the PHP code, and I added client side Javacript variables to a watch list. No problem.
I did run into a bit of a problem when I was trying to debug client side code that was inline in a PHP file. When I set a breakpoint in the Javascript portion of the PHP file, upon the break VS.PHP sent me off into the PHP code. It did not break exactly on the Javascript line.
Intelli-sense, PHPDoc Support, and Code Outlining
One thing that makes .NET coding such a breeze in Visual Studio is the abiltity to view a class's properties and methods with the aid of Intelli-Sense. As you type, the Visual Studio IDE automatically displays an object variable's properties and methods. VS.PHP adapts this capability to PHP coding, and it's just as compelling.
I defined some simple classes in a PHP file, then began writing code with them. VS.PHP identified the object variable that interested me by alphabetic sort in an inline drop-down, just as Visual Studio would if I were coding in C# or VB. Also, once I entered the PHP class delimiter characters ->, VS.PHP displayed all the fields and methods associated with the given class.
No comments:
Post a Comment