Skip to content

Commit 098e050

Browse files
authored
Merge pull request #20 from thecodeholic/url-params
Update core to version v1.0.5. Implement route params
2 parents 1a33843 + 95341ce commit 098e050

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
},
1414
"require": {
1515
"vlucas/phpdotenv": "^5.0",
16-
"thecodeholic/php-mvc-core": "^v1.0.4"
16+
"thecodeholic/php-mvc-core": "^v1.0.5"
1717
}
1818
}

controllers/SiteController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function home()
3838

3939
public function login(Request $request)
4040
{
41+
echo '<pre>';
42+
var_dump($request->getBody(), $request->getRouteParam('id'));
43+
echo '</pre>';
4144
$loginForm = new LoginForm();
4245
if ($request->getMethod() === 'post') {
4346
$loginForm->loadData($request->getBody());
@@ -85,4 +88,11 @@ public function profile()
8588
{
8689
return $this->render('profile');
8790
}
88-
}
91+
92+
public function profileWithId(Request $request)
93+
{
94+
echo '<pre>';
95+
var_dump($request->getBody());
96+
echo '</pre>';
97+
}
98+
}

public/index.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,19 @@
3232
$app->router->get('/register', [SiteController::class, 'register']);
3333
$app->router->post('/register', [SiteController::class, 'register']);
3434
$app->router->get('/login', [SiteController::class, 'login']);
35+
$app->router->get('/login/{id}', [SiteController::class, 'login']);
3536
$app->router->post('/login', [SiteController::class, 'login']);
3637
$app->router->get('/logout', [SiteController::class, 'logout']);
3738
$app->router->get('/contact', [SiteController::class, 'contact']);
3839
$app->router->get('/about', [AboutController::class, 'index']);
3940
$app->router->get('/profile', [SiteController::class, 'profile']);
41+
$app->router->get('/profile/{id:\d+}/{username}', [SiteController::class, 'login']);
42+
// /profile/{id}
43+
// /profile/13
44+
// \/profile\/\w+
4045

41-
$app->run();
46+
// /profile/{id}/zura
47+
// /profile/12/zura
48+
49+
// /{id}
50+
$app->run();

0 commit comments

Comments
 (0)