Flight is another micro framework written in PHP and bills itself as being extensively extensible.

Like other such frameworks, you begin (and arguably end) by creating a series of routes and adding closures to those routes that present the actions and outputs of said route. The quintessential example being as follows.

Flight::route('/hello', function(){
	echo 'Hello, World!';

The routing works really well using the simple format that allows you to name and route and add a regular expression match in one simple statement.


You don’t have to use closures either – any callable object can be used, so you can write a separate function and call it from multiple routes – useful if you have multiple, entirely separate patterns to match where it doesn’t make sense to do it all in one regular expression.

Flight has a simple built-in views system which allows you to render a view (which just uses PHP files to keep things simple) and pass an associative array of variables in which then translate to variables which you can use in the view. Layouts are also supported.

Its real power though is in how you can extend it. You can easily write your own classes and call them into your Flight methods using its register function.

Flight::register('db', 'Database');
$db = Flight::db();

This doesn’t just apply to new classes – you have override the Flight classes with your own if you wish to as well. Flight goes far deeper though, allowing you to do what it describes as filtering, a system which allows you to insert hooks before and after functions.

Flight is a great little framework, and one to rival Silex.



Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.


Tags: , ,

This entry was posted on Sunday, June 17th, 2012 at 12:47 pm and is filed under Limited, Programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.