Lightweight Applications

January 28, 2012

There are currently two demo applications generated by SIMPL/PHP.
These applications are standard PHP/CodeIgniter/MySQL code without any included SIMPL libraries or dependencies.

“demo2” uses the ExtJs library to create an application interface with layered panels selected by tab buttons (without using the TabPanel class).

“demo1” is a new demo that uses only HTML/CSS – there is no use of JavaScript at all.

Some of my applications are designed for use in areas that have (or may have) slow Internet connections.

Therefore, it is imperative not to requires users to download large JavaScript libraries.

SIMPL/PHP can build any kind of application – ExtJs, Ext-core, jQuery, or just HTML/CSS.

It is all a question of what SIMPL classes are used as templates and how the code generators are set up.

Documentation Builder

Documentation Builder

http://simplphp.com

Here is an image of a new documentation builder/browser that I just added to the site. This tool will help me with documenting my projects while at the same time serving as a general reference tool for those who are interested.

The tool can be opened by selecting “DocBuilder” from the “Launcher” window and clicking the “Open” button at the bottom. If the “Launcher” window is hidden, there is a context menu (right click) on the desktop that can be used to open it.

Use the ClassBrowser to see the SIMPL source code for the “DocBuilder” class:
Object->Widget->Window->WindowHSplit->DocBuilder

There are only a few methods in this class:
bbar – sets the toolbar at the bottom of the window
height – height of window
leftPanelCfg – what goes in the left panel
rightPanelCfg – what goes in the right panel
splitPos – the initial position of the vertical splitter bar
title – window title
width – width of window

Most of this is obvious, but two deserve more attention.
bbar – DocBuilderToolbar is found at Object->Widget->Toolbar->DocBuilderToolbar
leftPanelCfg – DocNamesList is found at Object->Widget->ListPanel->DocNamesList

There are only two methods for DocBuilderToolbar:
config – what buttons to place on the toolbar
table – what database table to use (“docs”)

And there are only two methods in DocNamesList:
config – some config info for the names grid widget
table – what database table to use (“docs”)

Finally, DocNamesList also refers to another class (in the config method):
DocStore found at: Object->Data->Store->DocStore

And there is only one method for DocStore:
config – sets up the server request

Notice that the server request consists of a SIMPL script:

collect(dblist(‘docs’),function(x){{‘name’:x}})

which gets a list of keys from the database, “collects” a list of dictionary objects (like Python list comprehensions), and returns the data structure back to the client as a JSON string.

And that is all there is to setting up a fully functional (CRUD) database editing/browsing tool.

The magic here is that DocNamesList inherits a lot of its functionality from its parent class, ListPanel.

DocBuilderToolbar inherits most of its functionality from its parent class, Toolbar.

The time it took to create the classes and methods for DocBuilder was probably about five minutes. And it was immediately available for use as soon as its classes were specified.

This kind of rapid app construction is typical of Smalltalk environments.

But in SIMPL/PHP, there is no Smalltalk – it is just pure vanilla PHP/HTML/CSS/JavaScript.

It just “feels” like Smalltalk for development…

Generated Application - "Demo 2"

Generated Application - "Demo 2"

SIMPL/PHP
Generated App – “Demo 2

This is a very simple application – just a set of styled containers using the custom CSS (generated by the CssFactory class) and some custom JavaScript (generated by the JavaScriptFactory class) for handling the selection tabs.

However, it has been built using the complete CodeIgniter/PHP framework with a newly generated default controller and view. It is deployed on an Amazon AWS/EC2 webserver.

The application is built using the “Demo2” class which generates all of the customized CSS, JavaScript, and ExtJs definition files.

I did a small experiment to see how long it took me to generate the application from a clean start. Here are the steps:

1) Use “FileBrowser” to clone the CodeIgniter libraries to the deployment directory.

2) Use AppBuilder to set the default controller name, set the default view name, “initialize” the app to use ExtJs, and set the code generator class.

3) Generate the custom code and build the required PHP files.

4) Done – the app is deployed.

Total time was about 53 seconds.

Of course more complicated apps will take a bit longer and, of course, there was the time to build the “Demo2” class itself.

But as the libraries get more comprehensive, creating a new application which is similar to something already existing in the library (by subclassing existing classes) will become very quick.

The created application is vanilla CodeIgniter-PHP-CSS-JavaScript-ExtJs – none of the SIMPL libraries are used in the deployed app.

If you look at the source code for the demo, you will see this meta-tag near the top:

The square brackets will hold an identifier of the SIMPL class generator used to build the application. This will be used for application maintenance in the future.

Custom ExtJs CSS Generation

January 23, 2012

CssFactory Class

CssFactory Class

http://simplphp.com

Demo 2

The “CssFactory” class can be used to generate custom styling for ExtJs containers (or for plain HTML).

Here is the CssFactory “standardStyle” method:

function(self) {
join([
send(self,'activetab'),
send(self,'cardbody'),
send(self,'cardpanel'),
send(self,'desktop'),
send(self,'footer'),
send(self,'footertext'),
send(self,'header'),
send(self,'inactivetab'),
send(self,'navbar'),
send(self,'newsbody'),
send(self,'newspanel'),
send(self,'outerpanel'),
send(self,'page'),
send(self,'signin'),
send(self,'spacer'),
send(self,'title'),
send(self,'titlehtml')
],'\n');
}

It simply concatenates a number of styles generated by other methods. Of course, you can make other styles using a different selection of methods.

Also, CssFactory can be subclassed making it possible to have a specific style generator for each project while still retaining a common style library for use across all projects.

The same technique applies to adding JavaScript functions through the use of JavaScriptFactory.

SIMPL is based on concept of having a large library of classes and re-using the classes for multiple applications.

This styling creates rounded edges for a series of nested “Ext.container.Container” classes.

Demo 2