Creating Custom Components

From Delphi for PHP Documentation Wiki

Jump to: navigation, search

Summary: Describes how to create a custom component.


Delphi for PHP makes it very easy to create custom components and integrate them into the Delphi for PHP IDE for use in developing your PHP applications. While you can write PHP components from scratch, it is faster to use the "New Component" wizard to create the basic skeleton of the component which you can customize. To create custom components

  • Choose Component Image:pathPDF.jpg New Component .This opens the "New Component" wizard.
  • Click the "Ancestor Type" drop-down arrow and choose one of the installed components on which to base your custom component.
  • Type the name for the new component in the "Classname" field.

For example, you could create a component based on the <keyword> Edit</keyword> component and name it  LabelEdit .

  • Click the drop-down arrow for the "Palette Page" field and select the page on which to install your this component.
  • Check "Create Package" to also create a new package for the component.
  • Click "OK".

The wizard creates two source files for the component: one for the component with the extension  .inc.php , and one for the package with the extension  .package.php . When you save the files, you can rename them from the default names assigned to them bye the wizard.


A VCL for PHP component must include  vcl.inc.php and the unit that controls the base class. The wizard automatically does this:

 
//Includes
require_once("vcl/vcl.inc.php");
use_unit("stdctrls.inc.php");
 

Now you can modify the component, save it, and install it on the "Tool Palette" for use in your applications.

Tip:

Create a subfolder for your custom components in the Delphi for PHP  vcl folder. That way you can build your own libraries without affecting the VCL code base and you can more easily deploy your components to other users.

Installing Custom Components

Adding an Image Icon to a Component

Creating Properties for Custom Components

Saving Custom Components

Setting Component Properties

Personal tools