Technical Highlights: Produce High Quality, Extensible PHP Scripts with Apeel PHP Code Generator Pro

Technical Highlights

If you've tried code generators in the past but weren't convinced then we can't say we blame you! Many early code generators (even early versions of ours) produced functioning Web Apps quickly alright, but the code was typically unwieldy procedural spaghetti code that was a nightmare to manually modify - now, things have changed.

A Framework Approach

When we undertook a major re-development of our flagship PHP code generator we decided to take an object-oriented, open source Framework approach, not just because it was trendy to do so but because we could see clear productivity and reliability benefits.

We had a simple mandate - find a flexible framework with a short learning curve, which is tried and tested, easy to "break out" of, and doesn't require any proprietary knowledge such as cryptic YAML files. We also wanted to avoid frameworks that force you to use "middleware" to connect to the database as we feel that whilst they hide the complexity of SQL from the developer, they also hide it's power too and sometimes create inefficient SQL behind the scenes. We feel that time spent learning SQL is time well spent for any developer, and in any case our Code Generator generates the SQL for you.

With so many frameworks around we thought this quest would be easy - but it wasn't! We looked at dozens of popular open-source frameworks, many of which are really good but failed one or more of our criteria.

We realised therefore that the only way we could meet all our criteria was to develop our own framework.

Introducing the APEEL Framework

In order to ensure that our Framework was rock solid and easy to learn we decided to use industry-standard open-source libraries as it's foundation to provide us much of the functionality as possible - e.g. Smarty for templating, JQuery for Ajax functionality, JQuery-UI for theming etc. Using the most popular libraries means that we could be sure they were tried and tested, many developers would already have experience of them, and for those that don't, time spent learning them is transferrable to other projects.

To tie it all together we developed lightweight classes based on the Model-View-Controller design pattern to ensure that most developers would already be comfortable with the structure, and others can easily learn it.

The end result is exactly what we set out to achieve - a reliable object-oriented open source Framework that is easy to learn, adapt and develop in, and break-out of.

The APEEL Framework is DRY

APEEL is structured on the principle of DRY (Don't Repeat Yourself). i.e. it is carefully structured using class inheritance to avoid code duplication - therefore making your code easier to manage.

The APEEL Framework is Easy to Adapt

Every developer works in a different way so we want the APEEL Framework to be YOUR framework. It is therefore written using highly readable code in sensibly structured classes which make it easy to adapt and extend to suit your needs.

How Apeel PHP Code Generator Pro Works

First it connects to your database to retrieve it's table/field structure. It uses artificial intelligence to seek out possibly foreign keys and work out suitable lookup type fields, user friendly labels and so on.

The user interface presents the Table/Field structure to use and allows you to change settings e.g. if it incorrectly matched a foreign key or you want to change the label which will be presented to the user for example.

When you click the Generate button and select your theme, language, location etc the first thing it does it to copy the standard Apeel Framework verbatim since these files do not change. These are created in the /Framework folder.

Next it creates the data object classes, form templates, form handlers and misc. files based on your database structure and chosen settings using template files located in /Dynamic folder. These are created in the /Application folder.

Within minutes you are ready to launch your Data Entry Web Application in your browser.

How to customise your Web Application

Apeel PHP Code Generator Pro generates a fully functional Data Entry Web Application with advanced Ajax forms and Search capabilities. But supposing you require some complex processing that is beyond the scope of a code generator - how do you go about hand coding?

First you need to decide where the customisation needs to go. If your application isn't working as you would expect then the first thing is to review the options in the Code Generator user interface itself. If something isn't quite right then correct it and re-generate.

The next thing to consider is the scope of the change - is it something you only wish to apply to one form, or is it something that you want to change universally? Are you adding new functionality or modifying existing functionality?

For a change that only effects one form for example, it would make sense to make changes to that form's Form Handler class. But if it's a universal change then it makes more sense to code the functionality into the core framework and just make the relevant changes to the Application class.

If you wish to restyle forms then changing the CSS and/or the form templates under the /Dynamic folder and regenerating the application is generally the way forward.

Want to know more?

There is more documentation on the Apeel Framework Website.

To peruse the source code of a demo application created for the MySQL Sakila database please View Source Code.