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.

Overview

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 PHP

When you start Delphi for PHP, you'll see a welcome screen that is similar to what you would see in Visual Studio. 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.

When you start a new project, you will be asked what kind of project to start. For this example, I chose a new Application. This allows us to work with a completely blank slate project. As you can see, the main work area is divided between a grid layout of the page and a source code view of the page. The toolboxes now contain information as well.

Getting down to business

Let's take a closer look at the Object Inspector (which is used to edit the properties, events, and JavaScript of objects), where much of the action takes place.

Again, this will look familiar to users of other IDEs. In this case, I will change the value of the Caption property from Unit1 to Test Page. As soon as I do, the <title> tag in the generated code is now changed to Test Page. The reason for this is, the caption property was part of the page itself, so it maps to the <title> tag of the page.

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.

As expected, you can drag and drop controls from the toolbox (called the Tool Palette) onto our page. In this example, I will place a text box and a button on the page. I can select the controls on the page with the mouse and use the Object Inspector to modify the associated properties, events, and JavaScript. The difference between Events and JavaScript is that Events handles things that occur server-side and JavaScript items are run on the client side. The OnClick event of a button, for example, is run on the server when a postback occurs as a result of clicking the button. So an object with JavaScript for OnClick and an event handler for OnClick would run the JavaScript, perform the page postback, and then run the event handler code on the server. Double clicking an object in the designer will take you to that object's default event handler and create an empty event handler if you have not already made one.

Making it look good

The final piece of the puzzle is to make the page look good. To do that, I will attach a style sheet by first creating a style sheet and adding it to the project. From the File menu, choose New, choose Other in the resulting dialogue box, select CSS in the tree on the left, and then click OK. If you have an existing style sheet that you would like to add to the project, you can do so through the Project menu.

Once you add the style sheet 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 style sheet 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 style sheet. 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 style sheet. 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 formalises the potential "division of labour" 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.

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.

Wide World of Web This was published in Wide World of Web, check every Wednesday for more stories

Comments

1

sohel - 25/02/09

2

bagslead - 06/04/09

now this delphi vension is free to download?

» Report offensive content

3

Sonny - 18/08/09

The fact that no other development environment can simulate what Visual Studio can for ASP, makes Delphi for PHP a good product.

Drag and Drop codes and Intellisense , DBGrid (GridView for ASP) , reminds me of VS .

» Report offensive content

4

Tyco - 02/09/09

Seriosly, DON'T use Delphi for PHP. It defines itself as a RAD IDE, but it isn't. In fact, building web applications with it is a real pain in the ass. It's taking too much time, it's bad documented and the performance of the VCL for PHP framework is crappy.

If you are a Delphi developer, considering to build web applications, don't use it. The difference is too big and the mix of PHP and Javascript is something you have to learn anyways.

If you are a PHP developer, considering to use a good framework to optimize your workflow, don't use it either. Instead, try to read yourself into the Zend framework.

If you are unsure, but you think a graphic IDE could save you a lot of time, don't use it. It will definitely not save you any time. Instead, try to get a grip on CSS and the different types of positioning elements.

I'm absolutely serious. Don't use it. It's a frustrating experience that will slow your web projects down to a near standstill. I have to use it for my current project and it's devastating.
I hope that somebody will read this _before_ buying Delphi for PHP.

» Report offensive content

5

Jamie Hall - 21/10/09

Hmmmmn. I can't see that it offers anything better than Eclipse PDT.

Eclipse PDT for PHP Development is excellent. It boasts a fantastic UI and plenty of useful plugins (such as the subeclipse for SVN). Oh, and the best thing is - it's entirely open source and free.

I'm not quite sure why 'Delphi for PHP' is trying to delve into the IDE market when there are already better and free ones out there already.

» Report offensive content

Leave a comment

You must read and type the 6 chars within 0..9 and A..F

* indicates mandatory fields.

5

Jamie Hall - 21/10/09

Hmmmmn. I can't see that it offers anything better than Eclipse PDT. Eclipse PDT for PHP Development is excellent. It boasts a ... more

4

Tyco - 09/02/09

Seriosly, DON'T use Delphi for PHP. It defines itself as a RAD IDE, but it isn't. In fact, building web applications ... more

3

Sonny - 18/08/09

The fact that no other development environment can simulate what Visual Studio can for ASP, makes Delphi for PHP a good ... more

Log in


Sign up | Forgot your password?

  • Staff Microsoft shows off IE9 preview

    This week, highlights from Microsoft's MIX10 conference and more in the Roundup. Read more »

    -- posted by Staff

  • Chris Duckett IE9's H.264 vote killed Ogg

    In a split decision by the judges, the winner of the W3C/WHATWG video codec consensus is H.264, taking home the future of video playback on the internet while loser Ogg goes home with nothing but thoughts of what might have been. Read more »

    -- posted by Chris Duckett

  • Staff Google launches Apps Marketplace

    Google launches and app store, while Mozilla plans to re-write its open-source license. More of this week's news in the Roundup. Read more »

    -- posted by Staff

What's on?

  • Optus Deal

    Broadband + home phone + PlayStation®3 in a single package price!