Welcome to ef

ef stands for Execution Framework and it is a single PHP file which lets you to write modular web applications in a new, experimental way.


The original motivation (dating 2004) behind the project was an observation that dynamic web sites are often just proxies to underlying modules. Their task is to translate users URL request into a bunch of subrequests and position obtained HTML responses on a web page. For example, main page of a portal site may consist of a search module, news listing and view of latest forum postings. Goal of this project is to make modules written in ef request-oriented and so flexible and independent, that they may be transferred between completely different web sites.

Second observation was that URLs close to each other (in terms of time and functionality) often share same "computations" made at the beginning of request handling phase. For example, actions of creating and editing a site user follow the same code path of creating a suitable HTML form; first action will stop here, and second will fill the form with actual data. Thus, goal of ef is to resemble this in modules file structure.


  • breaks code into multiple files and directories responsible for different functionality
  • simple PHP-based templates
  • simple support for internationalization
  • complete separation of computation from presentation

The idea

ef handles requests. A request consists of path and parameters, very similar to what a web browser does.

In order to handle the request, ef is given a "module root" directory (similar to HTTP servers docroot) with module implementations. ef traverses file system according to requested path. For example, if /var/ef is module root and /forum/user/edit path is requested, ef will start at /var/ef/forum, then cd into /var/ef/forum/user and finally /var/ef/forum/user/edit.

In each directory visited, ef executes file named action.php, if its present. This file is responsible for doing all computations needed at this level, exporting template variables and returning an exit code. Basing on this code, ef continues, stops at this level (with success) or aborts request at all. During this traversal ef registers the template structure for later usage.

Once the path end is reached, an object holding all exported variables and template structure is returned. The data may be further "poured" into HTML templates or directly exported in JSON format.

Simple example

Suppose you have following file structure:

  • htdocs/index.php - so called "interface"
  • ef.php - ef source code
  • myapp/ - exemplary application
    • myapp/action.php
    • myapp/foo/action.php
    • myapp/block-main.php
    • myapp/



include "../ef.php";

$myapp1 = ef_run("/myapp");
$myapp2 = ef_run("/myapp/foo", array("arg1" => "hello world"));

<head><title>Hi there</title></head>
Output of myapp1: <?= ef_tpl($myapp1) ?>
Output of myapp2: <?= ef_tpl($myapp2) ?>

myapp/action.php and myapp/foo/action.php

ef_outputs("myvar", "myarg");

$myvar = "level 1";
$myarg = $req["arg1"];

$myvar .= " and level 2";


<?= t("Hi there!") ?> -- myvar = <?= $myvar ?>, myarg = <?= $myarg ?>


$a = array("Hi there!" => "Cześć!");


<head><title>Hi there</title></head>
Output of myapp1: Hi there! -- myvar = level 1, myarg = 
Output of myapp2: Hi there! -- myvar = level 1 and level 2, myarg = hello world
Last modified 11 years ago Last modified on 02/18/10 19:43:06