Skip to content

Commit

Permalink
Implement possibility to get route params from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodeholic committed Feb 22, 2022
1 parent 4610df1 commit 2737906
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function home()

public function login(Request $request)
{
echo '<pre>';
var_dump($request->getBody(), $request->getRouteParam('id'));
echo '</pre>';
$loginForm = new LoginForm();
if ($request->getMethod() === 'post') {
$loginForm->loadData($request->getBody());
Expand Down
1 change: 1 addition & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
$app->router->get('/contact', [SiteController::class, 'contact']);
$app->router->get('/about', [AboutController::class, 'index']);
$app->router->get('/profile', [SiteController::class, 'profile']);
$app->router->get('/profile/{id:\d+}/{username}', [SiteController::class, 'login']);
// /profile/{id}
// /profile/13
// \/profile\/\w+
Expand Down

0 comments on commit 2737906

Please sign in to comment.