File tree Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Expand file tree Collapse file tree 1 file changed +45
-1
lines changed Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- echo "Hello World! " ;
5+ use Phalcon \Api \Domain \Services \Container ;
6+ use Phalcon \Mvc \Micro ;
7+
8+ require_once dirname (__DIR__ ) . '/vendor/autoload.php ' ;
9+
10+ $ container = new Container ();
11+ $ application = new Micro ($ container );
12+
13+ /**
14+ * Routes
15+ */
16+ $ routes = [
17+ [
18+ 'method ' => 'get ' ,
19+ 'pattern ' => '/ ' ,
20+ 'handler ' => Container::HELLO_ACTION ,
21+ ],
22+ ];
23+
24+ foreach ($ routes as $ route ) {
25+ $ method = $ route ['method ' ];
26+ $ pattern = $ route ['pattern ' ];
27+ $ handler = $ route ['handler ' ];
28+
29+ $ application ->$ method (
30+ $ pattern ,
31+ function () use ($ container , $ handler ) {
32+ $ action = $ container ->get ($ handler );
33+
34+ $ action ();
35+ }
36+ );
37+ }
38+
39+ $ application ->notFound (
40+ function () {
41+ echo "404 - Not Found - " . date ("Y-m-d H:i:s " );
42+ }
43+ );
44+
45+
46+ /** @var string $uri */
47+ $ uri = $ _SERVER ['REQUEST_URI ' ] ?? '' ;
48+
49+ $ application ->handle ($ uri );
You can’t perform that action at this time.
0 commit comments