A PHP port of @FTLabs's FruitMachine

v0.5.5 2014-04-27 12:50 UTC


PHP port of @FTLabs' fruitmachine, a lightweight component layout engine for client and server.

FruitMachine is designed to build rich interactive layouts from modular, reusable components. It's light and unopinionated so that it can be applied to almost any layout problem. FruitMachine is currently powering the FT Web App.

// Define a module
class Apple extends \FruitMachine\AbstractModule {

  public static $name = 'apple';

  public function template() {
    return 'hello'


$fm = \FruitMachine\Singleton::getInstance();

// Define a module

// Create a module
$apple = $fm->create('apple');

// Render it
echo $apple->toHTML();
//=> <div class="apple">hello</div>


To install from packagist either add mattandrews/fruitmachine to your project's composer.json file or enter the following on the command line:-

composer require mattandrews/fruitmachine


Unit tests are run on each build against PHP 5.3, 5.4 and 5.5.


Credits and collaboration

The lead developer of FruitMachine-php is Matt Andrews at FT Labs. All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions. Please feel free to raise an issue or pull request.