PHP code example of davro / fabrication

1. Go to this page and download the library: Download davro/fabrication 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/ */

    

davro / fabrication example snippets




$engine = new Fabrication\FabricationEngine();
$engine->input('hello', 'world');

echo $engine->output('hello');
#
# world
#




$template = '<html><head></head><body><div id="hello"></div></body></html>';

$engine = new Fabrication\FabricationEngine();
$engine->input('#hello', 'world');

$engine->run($template);

echo $engine->output('#hello');
#
# world
#

echo $engine->saveHTML();
#
# <html><head></head><body><div id="hello">world</div></body></html>
#

echo $engine->saveFabric();
#
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
#    "http://www.w3.org/TR/html4/loose.dtd">'.
# <html><head></head><body><div id="hello">world</div></body></html>
#




$template = '<html><head></head><body><div class="hello"></div></body></html>';

$engine = new Fabrication\FabricationEngine();
$engine->input('.hello', 'world');

$engine->run($template);

echo $engine->output('.hello'); 
#
# world
#

echo $engine->saveHTML();
#
# <html><head></head><body><div class="hello">world</div></body></html>
#

echo $engine->saveFabric();
#
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
#    "http://www.w3.org/TR/html4/loose.dtd">'.
# <html><head></head><body><div class="hello">world</div></body></html>
#