28/04
2017
Wallogit.com
2017 © Pedro Peláez
The goal of this project is to be able to write flask-like applications in PHP., (*1)
Clone down the repository inside your project, (*2)
And then:, (*3)
cd PHPFlask/
composer install
And then in your project:, (*4)
require_once('PHPFlask/src/index.php');
You can also install using composer:, (*5)
composer install sebbekarlsson/php-flask
Still clueless?, (*6)
class FruitsBP extends Blueprint {
var $fruits;
function __construct() {
parent::__construct();
$this->base_url = '/fruits';
$this->route('/', 'main');
}
function init() {
$this->fruits = [
'apple',
'banana',
'raspberry',
'papaya',
'orange'
];
}
function main() {
return json_encode($this->fruits);
}
}
And then registering it:, (*8)
$app->register_blueprint(new FruitsBP());
$app->route('/fruits', function() {
return json_encode([
'apple',
'banana',
'raspberry',
'papaya',
'orange'
]);
});