forked from liuggio/sized140
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
36 lines (29 loc) · 755 Bytes
/
index.php
File metadata and controls
36 lines (29 loc) · 755 Bytes
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
36
<?php
namespace Sized140;
include __DIR__ . '/../Sized140.php';
include __DIR__ . '/ui.php';
/**
*
* php -S 127.0.0.1:8080 index.php
*
* open the browser and go to http://127.0.0.1/something
*
*/
// Init Validation
$is = new Is();
$is->r =[
'string' => '/^[\S]+$/',
'not-null' => '/^/'
];
$blog = new BlogController($is);
// Init routes
$routes = [
'GET /(\w+)' => [$blog, 'get'],
'GET /' => [$blog, 'homepage'],
'POST /(\w+)' => [$blog, 'post']
];
$path_info = !empty($_SERVER['PATH_INFO']) ?: (!empty($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['REQUEST_URI']);
// Create the Response
$response = hub($path_info, $_REQUEST, $routes, $_SERVER['REQUEST_METHOD']);
// response
echo $response;