1. Go to this page and download the library: Download bcosca/fatfree 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/ */
php
$f3->route('GET @beer_list: /beer/@country', 'Beer->bycountry');
$f3->route('GET @beer_list: /beer/@country/@village', 'Beer->byvillage');
// a set of key-value pairs is passed as argument to named route
$f3->reroute('@beer_list(@country=Germany)');
// if more than one token needed
$f3->reroute('@beer_list(@country=Germany,@village=Rhine)');
php
$f3->set('var',value); // or
$f3->var=value;
$f3->set('hello.world','good morning'); // translates to: 'hello' == array('world'=>'good morning')
$f3->{'hello.world'}='good morning'; // same as prior statement
php
$f3->mset(
[
'foo'=>'bar',
'baz'=>123
]
);
php
echo $f3->get('var'); // or
echo $f3->var;
php
$f3->clear('var'); // or
unset($f3->var);
php
$f3->exists('var') //
isset($f3->var)
php
$f3->set('colors',['red','blue','yellow']);
$f3->push('colors','green'); // works like PHP's array_push()
echo $f3->pop('colors'); // returns 'green'
$f3->unshift('colors','purple'); // similar to array_unshift()
echo $f3->shift('colors'); // returns 'purple'
$f3->set('grays',['light','dark']);
$result=$f3->merge('colors','grays'); // merges the two arrays
php
$f3->set('ONERROR',
function($f3) {
// custom error handler code goes here
// use this if you want to display errors in a
// format consistent with your site's theme
echo $f3->get('ERROR.status');
}
);
php
$f3->set('DEBUG',3);
php
$f3->set('DEBUG',0);
php
$f3->config('setup.cfg');
html
<p>Hello, echo $name;
html
<p>Hello, <?= $name
php
$f3=ute('GET /',
function($f3) {
$f3->set('name','world');
$view=new View;
echo $view->render('template.htm');
// Previous two lines can be shortened to:-
// echo View::instance()->render('template.htm');
}
);
$f3->run();
php
$f3=ute('GET /',
function($f3) {
$f3->set('name','world');
$template=new Template;
echo $template->render('template.htm');
// Above lines can be written as:-
// echo Template::instance()->render('template.htm');
}
);
$f3->run();