Justin James guides you through a brief tour of CodeGear's Delphi for PHP, a visual IDE for developing applications in PHP. Find out what he thinks of the product.
After seeing the demo of CodeGear's Delphi for PHP product about a month ago, my initial impressions were that it was impressive. I recently got the chance to actually try out the product.
Here's a brief tour of Delphi for PHP, which I hope will help you bootstrap yourself into the environment. Because many regular readers are already familiar with Visual Studio, and because I am extremely familiar with it, I will be making many comparisons between Delphi for PHP and Visual Studio. Also, I won't spend time discussing the PHP language itself, but I will show how the work in the IDE affects the PHP code underneath.
Delphi for PHP is a visual IDE for developing applications in PHP. It is based on the same codebase as Delphi, and it implements a library of objects in PHP based on Delphi's Visual Component Library (VCL). This will make working in Delphi for PHP a familiar experience to current or past Delphi or C++ Builder users. It also means that PHP developers have access to a full suite of pre-made, object-oriented controls for use in their applications.
Welcome to Delphi for PHPWhen you start Delphi for PHP, you'll see a welcome screen that is similar to what you would see in Visual Studio (Figure A). There is a main window for code (which is initially occupied with links to open previous projects and files, news pieces, and so on), surrounded by toolboxes, project management windows, property viewers, and a code structure window, with a tabbed status/debugging window at the bottom. Figure A
It's interesting that the code displayed is generated directly from the object's properties and cannot be modified. While this may frustrate many users, the reasoning behind it is to eliminate odd discrepancies between the user's handmade changes and changes made in the IDE.
Making it look good
The final piece of the puzzle is to make the page look good. To do that, I will attach a stylesheet by first creating a style sheet and adding it to the project. From the File menu, choose New, choose Other in the resulting dialog box, select CSS in the tree on the left, and then click OK. If you have an existing stylesheet that you would like to add to the project, you can do so through the Project menu.
Once you add the stylesheet to the project, it is easy (but not obvious) to add it to the page. In the Tool Palette, you scroll down to the System group, select the StyleSheet control, and drop it onto the page. After the stylesheet is added to the page, you can select it and change the FileName property of the control in the Object Inspector to the name of your stylesheet. Once it is added, you will see that the Style property of the controls on your page has a drop-down list populated with the styles in the stylesheet. You will note that the Style property will not include any styles that do not apply to that type of control.
The code model
Delphi for PHP formalizes the potential "division of labor" between the presentation and the business logic. In PHP, it is possible to put all of the processing code embedded into the HTML code. But a good number of PHP developers choose to separate their code, putting all of the logic in a separate file and then including it in the file that is officially the page. In Delphi for PHP, there is a complete and formal separation between the code used for the presentation, and the code used for the logic.
UPDATE on 9/19/2008: A feature that I overlooked while writing this is that it is possible for the developer to create their own templates for the system, which in turn gives them control over the HTML. This feature was not intuitively obvious when using the product, and the documentation did not mention it in this context. If you require control over the HTML, you can have it, but it will require some additional effort on your part.
As hinted at earlier, the page's HTML cannot be edited; in fact, the HTML does not exist at design time. Instead, there is an XML file (disguised as a PHP file) that contains all of the properties, references to event handlers, and everything else that is controlled through the Object Inspector. At run time, this file is parsed, and the actual HTML for the page is generated. I am not so sure if I like losing complete control of the HTML and entrusting an HTML generator with this task. On one hand, more and more "Web developers" either do not use or do not know HTML very well and rely upon tools like Eclipse and Visual Studio to generate the code for their page. On the other hand, every PHP developer I know considers writing HTML by hand part and parcel of their job, and I am not sure if those folks would willingly give up control of the HTML.
The big picture
The relative lack of kludge that pervades systems such as ASP.NET and J2EE leads to Delphi for PHP being much less complex in operation and development, which is then reflected in the IDE itself. However, Delphi for PHP may seem too simplistic for many experienced ASP.NET and J2EE developers. I think that many current PHP developers may feel constrained by it, since they have come to expect the full control over HTML that other tools provide them. ASP.NET developers are used to giving up this control to various widgets. The best thing to do is to give the Delphi for PHP free trial a spin, and see if the product is for you.
J.JaDisclosure of Justin's industry affiliations: Justin James has a working arrangement with Microsoft to write an article for MSDN Magazine. He also has a contract with Spiceworks to write product buying guides.
-----------------------------------------------------------------------------------------------------------------Get weekly development tips in your inbox Keep your developer skills sharp by signing up for TechRepublic's free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!