µ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.
Get the code:
$ mkdir -p ~/php/uframework
$ wget https://raw.github.com/willdurand-edu/php-practicals/master/files/ufw.tgz -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 http://phar.phpunit.de/phpunit.phar
$ 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
The directory layout looks like this:
├ app/ # the application directory
├ src/ # the framework sources
├ tests/ # the test suite
├ web/ # public directory
└ autoload.php
Your application controllers will be registered as closures in app.php
.
Templates will be put into the templates/
directory.
The framework sources. You will have to complete the missing parts.
The test suite, all tests have to pass at the end :)
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.