forked from lastguest/mu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
48 lines (34 loc) · 796 Bytes
/
index.php
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
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* µ PHP microframework
*
* @author Stefano Azzolini <[email protected]>
*/
include 'mu.php';
/**
*
* Define routes callbacks with this syntax :
* µ::METHOD('ROUTE',CALLBACK);
*
* - METHOD can be GET,POST,PUT,DELETE,HEAD or some custom HTTP verb
* - ROUTE is the URL path fragment
* - CALLBACK is a callable object () invoked by the router.
*/
µ::GET('/',function(){
echo 'What is your name?';
echo '<form method=post><input type=text name=username><input type=submit></form>';
});
/**
* This is executed only when the browser call a POST on '/' route
*/
µ::POST('/',function(){
echo 'Hello ',$_POST['username'],', how are you?';
});
/**
* Invoke the phpinfo function on /php/info route
*/
µ::GET('/php/info','phpinfo');
/**
* Run the application
*/
µ::_();