Skip to content

Commit 877efa9

Browse files
committed
modify how resolve View
1 parent 87cd39b commit 877efa9

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/public/index.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
define('STORAGE_PATH', __DIR__.'/../storage');
55
define('VIEW_PATH', __DIR__.'/../views');
66

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']);
1314

1415

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+
}

src/views/error/404.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
404 Page

0 commit comments

Comments
 (0)