4
4
define ('STORAGE_PATH ' , __DIR__ .'/../storage ' );
5
5
define ('VIEW_PATH ' , __DIR__ .'/../views ' );
6
6
7
- $ router = new App \Router ();
8
- $ router
9
- ->get ('/ ' , [App \Controllers \HomeController::class,'index ' ])
10
- ->get ('/invoice ' , [App \Controllers \InvoiceController::class,'index ' ])
11
- ->get ('/invoice/create ' , [App \Controllers \InvoiceController::class,'create ' ])
12
- ->post ('/invoice/create ' , [App \Controllers \InvoiceController::class,'create ' ]);
7
+ try {
8
+ $ router = new App \Router ();
9
+ $ router
10
+ ->get ('/ ' , [App \Controllers \HomeController::class, 'index ' ])
11
+ ->get ('/invoice ' , [App \Controllers \InvoiceController::class, 'index ' ])
12
+ ->get ('/invoice/create ' , [App \Controllers \InvoiceController::class, 'create ' ])
13
+ ->post ('/invoice/create ' , [App \Controllers \InvoiceController::class, 'create ' ]);
13
14
14
15
15
- echo $ router ->resolve (
16
- $ _SERVER ['REQUEST_URI ' ],
17
- strtolower ($ _SERVER ['REQUEST_METHOD ' ])
18
- );
16
+ echo $ router ->resolve (
17
+ $ _SERVER ['REQUEST_URI ' ],
18
+ strtolower ($ _SERVER ['REQUEST_METHOD ' ])
19
+ );
20
+ }catch (\App \Exception \RouteNotFoundException $ e ) {
21
+ //header('HTTP/101 404 Not Found');
22
+ http_response_code (404 );
23
+ echo \App \View::make ('error/404 ' );
24
+ }
0 commit comments