Delphi for PHP quick start

By: John Kaster

Abstract: A brief introduction to installing and using Delphi for PHP

    What is Delphi for PHP?

Delphi for PHP is a new product from CodeGear for developing with PHP applications, modules, libraries and components "the Delphi way." Delphi for PHP is a Rapid Application Development (RAD) environment with a designer, editor, debugger, deployment wizard, and component framework called "VCL for PHP."

Our existing Delphi customers will find it extremely familiar. We hope PHP developers will find it very productive, fun, and friendly to use.

    Installing Delphi for PHP

While Delphi for PHP applications can run on any device supporting PHP, the integrated development environment (IDE) is only supported on the Microsoft Windows platform in this release. After you have your installation file for Delphi for PHP, you can run the installation tool.

When you run the install, you will first see this screen.

Hide image

Click Next, and you'll see a license agreement dialog.

Hide image

The text won't be blurry like it is in this screen shot, however!

If you click I accept the agreement and Next, you'll see a dialog similar to the following:

Hide image

Specify the folder for your install, and click Next.

Hide image

You can change the name of the Start Menu folder if you want, and click Next.

Hide image

Decide whether you want to create a desktop icon or not, and click Next.

Hide image

If your installation choices are correct, click Install.

Hide image

The install will start running. At any time, you can click Cancel to roll back the installation process and cancel the install. Hide image

After the installation completes, you are ready to use Delphi for PHP. If you leave the checkbox checked and click Finish, the IDE will load. Everything you need to develop and test a PHP application on your local machine has been installed and configured, including PHP, Apache, InterBase and MySQL Database engines and PHP connectivity for them.

    Delphi for PHP IDE overview

The Delphi for PHP IDE is written in Delphi, but it is not currently part of the Galileo IDE, which is the host environment for Delphi, C++Builder, and C#Builder. It should be very familiar to any Delphi, C++Builder or C#Builder developer however. We have made it as similar to the developer studio IDE as possible for this first release.

The first thing you will see is the attractive splash screen.

Hide image

    Default IDE layout

When the IDE first loads, the welcome page and the default layout view is displayed.

Hide image
Click to see full-sized image

    Welcome page

The welcome page provides direct links to recent projects, recent files, and headlines relevant to Delphi for PHP. The headlines are provided automatically from RSS and/or atom feeds published by CodeGear, and are only updated when you are connected to the internet.

Hide image
Click to see full-sized image

    Creating a project

To create a new project, click the New button on the welcome page, select the File | New menu item and pick the option you want to create.

Hide image

If you click New or select Other you will see this dialog:

Hide image

Select Application and click OK. This will create the application and present the design interface to you.

    New PHP application

Hide image
Click to see full-sized image

As you can see, the Welcome page has been replaced by the PHP form designer. The Code Explorer tab is populated with an outline of navigation points for your form. The Object Inspector allows you to edit the properties of the selected item on the design surface. (Right now, the selected item is the form itself.) The Project Manager shows all files related to this project (or group of projects). The Tool Palette lists all the components you can drag and drop onto the form designer.

    Designing the form

Now that the blank form is displayed in the designer, we can drop the components onto it directly from the tool palette. So, let's drop an Edit, ListBox, and Button component onto the form. I'll resize the Edit so it is the same width as the ListBox, and put the Button to the right of the Edit control.

Hide image
Click to see full-sized image

Note: You can also double click on a component to put a copy of it on the center of the design surface and move it from there.

Next, I'll change the caption for the button to "Add" in the object inspector, and double click on the button to create its click event.

Hide image
Click to see full-sized image

This creates the event stub for the button click event, and puts me in the source code editor right inside the click event. I'm ready to type my code. The final version of the Button click event is:

function Button1Click($sender, $params)
{
$this->ListBox1->Items[] = $this->Edit1->Text;
}

When the application is run, the browser looks something like this:

Hide image

We can type text in the edit box, and click the Add button to prove how easy and fast it is to design and build applications with Delphi for PHP.

Hide image

    Stay tuned

Stay tuned for more information on Delphi for PHP. This article is intended to introduce the basic concepts of Delphi-style development for PHP, but there is much more to cover for the rich world of PHP development!

Server Response from: ETNASC03