Create a PHP Component

Categories: Programming, Web
Comments: No Comments
Published on: September 17, 2012

While still working with a PHP web server application, let's create a simple component, install it, and modify the Hello World app to use it.

The tutorial says to always put components into the RPCL folder and separate them by company name. So if you get third-party components, they would show up as sub-folders in the RPCL. But since the RPCL folder is under Program files, which is protected in Windows Vista and onward, that's not going to work for developing one. So what I did is use a little trick to make the RPCL think my components folder is there by creating a link to my actual development folder which resides somewhere else.

By default, HTML5 Builder projects are created under “HTML5 Builder\Projects” in the “My Documents” folder. So I created a Components folder in there and then created a link to it in the RPCL folder.

To digress just a bit, I'll explain how to create that link. There's a command-line utility, MKLINK, that comes with Windows Vista and Windows 7–and newer I presume. (If you're on Windows XP or earlier, you'll need a free tool from Microsoft, SysInternals Junction. The parameters will be a little different than listed here, but it should be simple to figure out.)

Start a command prompt as administrator and navigate to the installed folder for HTML5 Builder (for me: cd “\Program Files\Embarcadero\HTML5 Builder\5.0\rpcl”). Then enter the command: mklink /j CorneliusConcepts “C:\Users\david\Documents\HTML5 Builder\Components”. This will create a link in the RPCL folder called, CorneliusConcepts, to the “Compnents” folder in my working folder. Of course, you'll want to substitute your name or business for mine and your username in place of mine.

OK, back to component making, the tutorial says to go to Home > New > HTML5 Builder Projects > PHP Files, but you really need to go to Home > New > Other Projects / Other Files and there you will find the Component icon. From there, follow the tutorial for the most part, giving the right paths for your environment.

When the two files are saved, the package file that sets the title and registers the component, and it's component include file which contains the code for the descendant component, you can close all files, select Packages, and add the package file to the registered components. If all goes well, you'll see a new component when you're in design mode that you can place on the form.

Follow this tutorial further to add properties and so forth to expand on this concept.

Leave a Reply

Your email address will not be published. Required fields are marked *

*



Welcome , today is Wednesday, August 23, 2017