PHP code example of mattandrews / fruitmachine

1. Go to this page and download the library: Download mattandrews/fruitmachine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mattandrews / fruitmachine example snippets


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

  public static $name = 'apple';

  public function template() {
    return 'hello'
  }

}

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

// Define a module
$fm->define('\Apple');

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

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