Archive for the 'PHP' Category

WebORB for PHP v1.3.2

Thursday, January 18th, 2007

I have been hearing a lot about Weborb for PHP so I decided to check it out for myself. If you are not familiar with Weborb, it is a server based technology that provides a Flex RPC service implementation which exposes remote PHP objects to a Flex client via remoting utilizing AMF3.

WebORB for PHP can be installed in your server root on any web server which supports PHP 5. Weborb for PHP is very easy to use and the documentation is good. I had it installed and got the sample application up and running in about 5 minutes.

Weborb for PHP is similar to AMFPHP in many respects. Both Weborb for PHP and AMFPHP alpha 1.9 provide AMF3 support. Neither requires FDS. All in all they both provide similar solutions, just in different ways.

If you are a Flex developer who builds backends in PHP, or if you are a PHP developer who is interested in developing rich client applications in Flex then Weborb for PHP is definitely worth a try.

You can check out the simple start up tutorial at the Weborb site. You can also check out WebORBPHPRemoteGateway, which is a generic base class I wrote that developers can extend for use in a Weborb for PHP Flex application.

AMFPHPRemoteGateway API update

Saturday, January 6th, 2007

I have modified my AMFPHPRemoteGateway API to only support ActionScript implementations.

The AMFPHPRemoteGateway class is now to be considered a base class, not necessarily a pseudo-abstract class, but rather a base class in which sub-classes can build on to implement specific remote method invocation. You can still use AMFPHPRemoteGateway directly as well for general purposes.
Sub classes of AMFPHPRemoteGateway should now implement mx.rpc.IResponder and pass a reference of themselves to the new addResponder(); method.

I have also added a generic DAO interface which implementors can utilize to perform typical create, read, update and delete (CRUD) operations on a persisted object. The new interface, IDAO, provides a default contract which can be implemented by AMFPHPRemoteGateway sub-classes for specific remote DAO invocation.

I suggest that users create individual sub-classes of AMFPHPRemoteGateway for each domain object in which to perform CRUD operations on.

You can view the docs as well as download the swc. There is also a project folder in the download which contains a basic usage example.

Introducing Cairngen

Thursday, January 4th, 2007

Introducing Cairngen: Adobe Cairngorm Code Generator

Overview:
A tell tail sign of a well designed architectural framework is in it’s ability to facilitate code generation. And Adobe Cairngorm does just that.

Cairngen is a tool in which I originally developed for myself in order to save time. I am sharing it with the Flex community as I believe that it is a very useful tool and it has saved me countless hours to date.

Cairngen is not intended to be all thing to all people, it is simply intended to speed up the development process. My hopes are that the Cairngorm team will take this idea and improve upon it by developing a proper Eclipse Plugin.

Cairngen is a code generator for Adobe Cairngorm which allows developers to easily and consistently generate Cairngorm project structures for Flex which consist of the standard Cairngorm folder structure, a default ModelLocator, Controller, and ServiceLocator. Cairngen also allows developers to generate Event, Command and Delegate classes.

Cairngen is a solution which removes the additional development time spent creating Cairngorm projects and classes and enforces consistency when developing a project with Adobe Cairngorm.

Cairngen was developed entirely in Flex 2 and PHP 5.2.0 utilizing AMFPHP via AMF3. Initial set up is easy and straightforward. You can run Cairngen from a browser instance inside of Flex Builder to quickly and easily generate Cairngorm classes. Cairngen will stub out all of your Cairngorm classes for you, all you ever have to do is implement them.

Cairngen uses the term ‘Sequence’ to describe the relationship between Event, Command and Business Delegate classes, and is not to be confused with a Cairngorm Sequence Command. In Cairngen you can quickly add a Sequence simply by naming the Sequence and clicking generate. You can then re-fresh your Flex Project and the classes will be stubbed out and ready for your specific implementation. In certain cases you may not need to add a delegate to your sequence in which case you can choose to exclude the delegate from being generated. Cairngen will then generate an Event and Command class for the sequence. The Command class will implement Cairngorm Command and not mx.rpc.IResponder. Cairngen will also handle casting events to the correct type in a Command as well as importing all associated classes.

As of this preview, Cairngen does not allow developers to overwrite existing files. This restriction is intentional in order to prevent developers from unintentionally overwriting files.

System requirements:
This informal documentation assumes that you are familiar with AMFPHP, Apache 2.0.59 and PHP 5.2.0. In this preview of Cairngen you must have amfphp installed on localhost as the Flex UI will need to resolve the AMFPHP gateway.php as follows: http://localhost/amfphp/gateway.php. In the final version 1.0 release this location will be configurable.

You will need to install Adobe Flex 2, PHP and AMFPHP on your local machine. To install PHP and Apache 5.5 in one quick and easy bundled windows installer use WAMP5. Run the WAMP5 installer and when completed, start the wamp5 service. Once PHP and AMFPHP are installed you will need to extract the Cairngen Alpha 1 PreRelease.zip to your local disc. Copy the services directory and paste it in the root of your amfphp directory. Then copy the cairngen-ui folder to your www root directory so as to reside in the same sandbox as the services directory.

Usage:
Once you have PHP and AMFPHP installed and running, you are ready to start using Cairngen. Open a browser and run the generator UI from http://localhost/cairngen-ui/Cairngen.html. You can launch cairngen.html as a browser instance in Eclipse as well.

To create a Cairngen Project:

  1. Click begin
  2. Name your Cairngen Project. This name is typically the same name as your Flex Project
  3. Select the Adobe Cairngorm version you want to work with (In this pre-release only Cairngorm version 2.0 is available)
  4. Select the location of your flex Project. (e.g; C:\workbench\EricFeminella\Cairngen)
  5. Set the com directory for your project (e.g; com.domain.projectname)
  6. Finally, verify that all locations and names are correct. If so click “Create Project”.
  7. Refresh your Flex Project to view the default Cairngorm project structure, ModelLocator, Service and Controller classes

To create a Sequence:

  1. Name the Sequence
  2. Select Include delegate to add a Business Delegate, or Exclude Delegate if the sequence does not require a service
  3. Click generate and refresh your Flex Project. The stubbed out classes are now ready to be implemented. You will need to add them to your Controller.

Editing template files:
You can modify the template files (.tpl) in order to reflect your particular implementation of Cairngorm; however, I strongly advise that you’re implementation is inline with Cairngorm best practices. The template files can be found in: amfphp\services\com\ericfeminella\cairngen\templates.

Updates:
In the final release of Cairngen the following additional requirements will be implemented:

  1. Ability to specify any root directory in which to generate classes to. As of this pre release you are restricted to a single com.domain.project directory as the project root.
  2. Read / write capabilities will update a Controller and add additional addCommand(); calls so that adding Event / Command mappings will be automated. As of this pre release you must add them manually.
  3. Local persistence will enable you to open and work with existing Cairngen projects as well as add new ones. As of this pre-release you can only work with a session based Cairngen project.
  4. Templates for Cairngorm 2.1. As of this pre-release only Cairngorm 2.0 is available. However, Cairngen will implement mx.rpc.IResponder for generated Command classes.
  5. Proper folder browsing will be implemented. Unfortunately in this preview you must type or paste the location of a Flex Project manually.

Licensing:
Cairngen is an open source project protected under the MIT license.

I will begin to formally document Cairngen over the course of it’s development. In the meantime enjoy the extra time that you will gain from using Cairngen.
Feel free to post your comments and suggestions.

Download Cairngen Alpha 1 Preview

AS3 PHP LoginService API

Wednesday, October 18th, 2006

This morning I wrote a quick API which allows you to easily invoke a PHP script from Flex 2, run a query on a MySQL database for authentication, and pass the results of the query back to the Flex client. The API consists of a simple login value object and a QueryService that calls an accompanying PHP script. The PHP script then runs a query based on the login value object passed in the query string as name value pairs.

The AS3 PHP LoginService API is intended to simply serve as a base class only. It is to be used as a starting point from which you can create a real world application based on sub-classing the QueryService to apply an MD5 encryption algorithm and so forth.

You can check out the example, accompanying ASDoc and source code as well as a Cairngorm 2.0 implementation which I created.