Routing with Named Parameters in PHP

Let's consider one of the regular expressions that process the URL:

index.php<?php
  if (preg_match('#^/page/([a-z0-9_-]+)$#', $url, $params)) {
    $page = include 'view/page/show.php';
  }
?>

In this case, our parameter ends up in a capture group. Then we extract the parameter value from the capture group by its number:

view/page/show.php<?php
  $slug = $params[1];
?>

This is actually not very elegant, especially if there are several parameters. A better idea would be to have parameters with names instead of numbers. To do this, we use named capture groups in our regex:

index.php<?php
  if (preg_match('#^/page/(?<slug>[a-z0-9_-]+)$#', $url, $params)) {
    $page = include 'view/page/show.php';
  }
?>

In this case, we can get the value of the parameter by its name:

view/page/show.php<?php
  $slug = $params['slug'];
?>
Задание 1

Convert the parameters in your engine's routes to named ones.