Flight::app

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
# requred libraries
require './lib/flight/Flight.php';
require './lib/fenom/Fenom.php';
# autoloaders
Fenom::registerAutoload();
Flight::path('./app/rest');
# fenom template engine
Flight::register(
'view', 'Fenom::factory',
array('./app/views','./app/cache',
array('auto_reload' => true, 'force_compile' => true))
);
# database connections
Flight::register('db', 'PDO', array('mysql:host=localhost;dnbname=test','root',''),
function($db){
$db->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES utf8');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
});
# routing apps
Flight::route('/', array('index','main'));
Flight::route('/signup', array('index','signup'));
Flight::route('/login', array('index','login'));
# routing ajax
Flight::route('POST /ajax/signup', array('ajax','signup'));
# app starting
Flight::start();