WebFu: Web Development Framework

Introduction

The WebFu framework is a set of libraries and domain specific language(DSL) compilers to be used for the rapid development of secure and maintainable multiuser web applications. The WebFu compilers currently target PHP 5, but other languages and platforms may be targetted based on demand. It is free for use with academic and open source packages, and a commercially licensable version will be available at later date for purchase and use with commercial applications.

Work in Progress

The WebFu framework is currently a work in progress, but is the underlying technology behind MetaPIM and Premier Horse Show Management System as well as several custom apps we have developed(If you do use the WebFu framework in your app, we would appreciate it if you would contact us and give us feedback

We realize the documentation is not clear, the concepts not always well defined, our code is lacking style and correctness. Even better, we're writing a framework when there are some many others to choose from. In some ways, our framework is probably closest in style to Links and Google Web Toolkit. However, we were aware of neither these when we began, we were only trying to codify patterns and solutions we were using to write webapps. Our company is a young, bootstrapped startup. We're releasing this to get feedback on our work, and we hope you find something of value here.

Table of Contents

This is not a full public release.

Components

WebFu consists of several pieces, not all of which are publicly available yet.

Web Functions

Web Functions are a way of mapping URL's and forms to user code to handle the requests.

The main concepts of Web Functions are roles, types, and delegates. A form of role based security is implemented by way way of "Role Classes". For each role you define(at the beginning of the script), an accompanying class is generated("CmdRole.php"), this class only implements the methods allowed for that role.

The delegates are PHP class methods that are invoked when that command is issued. They can be changed depending on the role, and the prototype for the method has the same number and order of parameters as the Web Function. So a Web Function GET foo(a INTEGER,b ARRAY[INTEGER], c STRING) that delegated to cls::meth would have in the class definition, public function meth($a, $b, $c)

The types are processed by pulling out the form or querystring parameter based on the parameter name and processed by a class named TypeFormTypenam that implements TypeForm. So:GET foo(a INTEGER,b ARRAY[INTEGER], c STRING) would invoke TypeFormInteger on $_GET['a'], TypeFormString on $_GET['b'], and TypeFormArray for the third parameter. The Array type is an illustrative example of what can be done with classes for processing types, in this case, it would look for $_GET['c0'], $_GET['c1'], $_GET['c2'], ... until no more form parameters have a name that matches that pattern.

The three return types are GET, POST, XMLHTTP. GET pulls parameters from $_GET and assumes that result is a string to be echoed to the browser. POST pulls parameters from $_POST and assumes that result is a url to redirect the browser to. XMLHTTP pulls parameters from $_REQUEST and assumes that result is a string to be echoed to the browser.

The class CommandFactory instantiates a class for a particular role based on the value of $_SESSION['cmdcls'] or the PHP constant DEFAULT_CMD if the session variable is undefined.

The function doGetCmd assumes that either $_GET['cmd'] or $_POST['cmd'] contains a string correpsonding to the Web Function to invoke.

Here is some example code from MetaPIM:

[ NULL, User, Admin ]

GET main()                      [ NULL ]    PIM::marketing
                                [ User ]    PIM::userMain
                                [ Admin ]   PIM::adminMain;

GET forgotPasswordForm()        [ NULL / User / Admin ] Account::forgotPasswordForm;

/*****************************************
	Note keeping commands.
*****************************************/
GET viewNotes(allNotes BOOLEAN) [ User ]    PIMNotes::view;
GET editNote(NoteID INTEGER)    [ User ]    PIMNotes::edit;
POST saveNote(NoteID INTEGER,
    title STRING,
    note STRING,
    closed BOOLEAN,
    tags STRING,
    pid INTEGER)                [ User ]    PIMNotes::save;
GET newNote()                   [ User ]    PIMNotes::form;
POST addNote(title STRING,
    note STRING,
    closed BOOLEAN,
    tags STRING,
    pid INTEGER)                [ User ]    PIMNotes::add;
POST delNote(NoteID INTEGER)    [ User ]    PIMNotes::del;
POST closeNote(NoteID INTEGER)  [ User ]    PIMNotes::close;
POST openNote(NoteID INTEGER)   [ User ]    PIMNotes::open;
				

Coming Soon, in addition the rest of the framework, Web Functions is getting Wildcard roles added and the ability to include other scripts.

Downloads

Dependencies: The compilers are implemented in Java 1.5 and will require a suitable JVM. All PHP is assumed for PHP 5, earlier versions are not going to be supported.


Licensing

The WebFu framework is currently available under the terms of the license below, which is a slightly modified version of the Q Public License


The Metanotion Public License version 1.0

Copyright © 2006 Metanotion Software.
Everyone is permitted to copy and distribute this license document.

The intent of this license is to establish freedom to share and change the software regulated by this license under the open source model.

This license applies to any software containing a notice placed by the copyright holder saying that it may be distributed under the terms of the Q Public License version 1.0. Such software is herein referred to as the Software. This license covers modification and distribution of the Software, use of third-party application programs based on the Software, and development of free software which uses the Software.

Granted Rights

1. You are granted the non-exclusive rights set forth in this license provided you agree to and comply with any and all conditions in this license. Whole or partial distribution of the Software, or software items that link with the Software, in any form signifies acceptance of this license.

2. You may copy and distribute the Software in unmodified form provided that the entire package, including - but not restricted to - copyright, trademark notices and disclaimers, as released by the initial developer of the Software, is distributed.

3. You may make modifications to the Software and distribute your modifications, in a form that is separate from the Software, such as patches. The following restrictions apply to modifications:

a. Modifications must not alter or remove any copyright notices in the Software.

b. When modifications to the Software are released under this license, a non-exclusive royalty-free right is granted to the initial developer of the Software to distribute your modification in future versions of the Software provided such versions remain available under these terms in addition to any other license(s) of the initial developer.

4. You may distribute machine-executable forms of the Software or machine-executable forms of modified versions of the Software, provided that you meet these restrictions:

a. You must include this license document in the distribution.

b. You must ensure that all recipients of the machine-executable forms are also able to receive the complete machine-readable source code to the distributed Software, including all modifications, without any charge beyond the costs of data transfer, and place prominent notices in the distribution explaining this.

c. You must ensure that all modifications included in the machine-executable forms are available under the terms of this license.

5. You may use the original or modified versions of the Software to compile, link and run application programs legally developed by you or by others.

6. You may develop application programs, reusable components and other software items that link with the original or modified versions of the Software. These items, when distributed, are subject to the following requirements:

a. You must ensure that all recipients of machine-executable forms of these items are also able to receive and use the complete machine-readable source code to the items without any charge beyond the costs of data transfer.

b. You must explicitly license all recipients of your items to use and re-distribute original and modified versions of the items in both machine-executable and source code forms. The recipients must be able to do so without any charges whatsoever, and they must be able to re-distribute to anyone they choose.

c. If the items are not available to the general public, and the initial developer of the Software requests a copy of the items, then you must supply one.

Limitations of Liability

In no event shall the initial developers or copyright holders be liable for any damages whatsoever, including - but not restricted to - lost revenue or profits or other direct, indirect, special, incidental or consequential damages, even if they have been advised of the possibility of such damages, except to the extent invariable law, if any, provides otherwise.

No Warranty

The Software and this license document are provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESSFOR A PARTICULAR PURPOSE.

Choice of Law

This license is governed by the Laws of the United States of America. Disputes shall be settled by the Tennessee Court System.