PHP code example of deathbeam / fwphp
1. Go to this page and download the library: Download deathbeam/fwphp 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/ */
deathbeam / fwphp example snippets
$fw->route('GET /@name',
function($fw, $params) {
echo'Hello, '.$params['name'].'!';
}
);
$fw->set('public_dir', 'new_public_dir');
$fw->cookie = 'cookie.php';
$fw->route('GET /', 'index');
$fw->config('config.json');
$fw->draw('test.php');
$fw
->set('header','This is example header')
->set('body','Content goes here')
->set('footer','This is example footer'))
->draw('default.php');
// mapping routes
$fw->route('home: GET|POST /', 'home');
$fw->route('GET /users', 'users');
$fw->route('users_show: GET /users/@id', 'showUser');
$fw->route('users_do: POST /users/@id/@action', 'userController->@action');
// provide ReST interface by mapping HTTP requests to class method
$fw->route('MAP /rest', 'some_class');
// default route (404 page)
$fw->route('default', 'error');
// redirect
$fw->reroute('users_show', array('id' => 5));
$fw->reroute('/users');