Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (55 sloc) 2.13 KB

Meet µFramework

µFramework is your micro-framework, the one you are going to build in the next practicals. Its API is heavily inspired by existing micro-frameworks such as Silex or Slim.

Getting Started

Get the code:

$ mkdir -p ~/php/uframework
$ wget -O ~/php/uframework/ufw.tgz
$ cd ~/php/uframework
$ tar xvzf ufw.tgz
$ rm !$


PHPUnit is a PHP testing framework part of the xUnit family. To install it globally, you can run the following commands:

$ wget
$ chmod a+x phpunit.phar
$ mkdir ~/.bin
$ mv phpunit.phar ~/.bin/phpunit

Edit (or create) your .bashrc to add the ~/.bin directory to your PATH.

Run a test suite using the following command:

$ phpunit

Anatomy of µFramework

The directory layout looks like this:

├ app/      # the application directory
├ src/      # the framework sources
├ tests/    # the test suite
├ web/      # public directory
└ autoload.php

app directory

Your application controllers will be registered as closures in app.php. Templates will be put into the templates/ directory.

src directory

The framework sources. You will have to complete the missing parts.

tests directory

The test suite, all tests have to pass at the end :)

web directory

Contains the public files. Most of the time, we put assets (CSS, JS files) and a index.php file.

The index.php file is the only entry point of your application. It is called a front controller.


In the previous practical, you wrote a PSR-0 compliant autoloader. The µFramework has a autoload.php file, but it iss empty.

Fix it!

Run the test suite to ensure everything works:

$ phpunit

Cool. See you next week!

You can jump to: Practical Work #3.