Posts Tagged ‘flight’

Amazon Prime Air

Monday, December 2nd, 2013 | Video

Looks pretty cool. I’m still expecting to find the bit where they say “only joking of course”.

Wing Commander using Composer

Wednesday, November 14th, 2012 | Programming

Back in July, I wrote about Wing Commander, a little library I had written to draw together the very awesome Flight PHP framework and Mustache.php template library.

Times have changed though and everyone is using Composer now (you are using Composer, right? 😉 ), not to mention that even at the time, Wing Commander was using a slightly dated version of the Mustache library. So I decided it was time for an update.

Said update was then completed in a lunch break (and a bit of an evening too) and is now available, and listed on Packagist, which means you can easily install it via Composer.

	"require": {
		"xmeltrut/wing-commander": "dev-master"

That is all you need in your Composer configuration file, and it will install Flight, Wing Commander and Mustache – plus, it’s now even easier to use than it was before. Full information can be found in the readme.

Wing Commander

Thursday, July 5th, 2012 | Limited, Programming

Moustache I’m a big fan of the Flight PHP micro framework, and it’s built-in views component is quite nice when you want to do stuff in a rush.

But recently I have started to use Slim more often as it has almost out of the box support for Mustache templates, whereas Flight does not.

Until now, that is. I wanted to use Mustache with an existing project I had already coded up in Flight, so I’ve now written a wrapper for it and released it on Github. It’s nothing fancy – probably less than 100 lines of code in total. But it seems to get the job done.

So if you’re looking to use Mustache templates in your Flight application, why not give it a go? If you have any improvements, you can always fork it too!

Creating a simple view helper in Flight

Monday, June 18th, 2012 | Limited, Programming

Recently I wrote about the Flight PHP micro-framework. One of the challenges I ran into when launching one of our sites in it was that we had some database information that needed to be pulled out in the layout.

It was the same information on every page so it didn’t make sense to pass it in as a variable as this would have meant using the same code on every route to do the same thing. Instead, it was simpler to create a view helper which would pull out the information needed.

class Helper {

	public static function menuTags () {
		$tagModel = Flight::tagModel();
		return $tagModel->findDistinct();


Nothing fancy here, just a static method on a class which hooks into one of the model classes I has already registered with Flight and returns the result. I then just needed to reference this from the layout view.

<?php foreach (Helper::menuTags() as $tag) { ?>
<?php } ?>

Now it appears on every page without me having to pass it in as a variable.


Sunday, June 17th, 2012 | Limited, Programming

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.