dannyvankooten / PHP-Router

Simple PHP Router class (supports REST and reverse routing)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php 8.1 - Unknown named parameter

Pok4 opened this issue · comments

commented
  • PHPRouter version: 1.2alpha
  • PHP version 8.1 via XAMPP - Windows 10

Hello guys i have this code:

$page_name_get = $dbh->prepare("SELECT menu_type FROM ".getenv('DB_PREFIX')."pages WHERE page_name=?");
$page_name_get->bindParam(1, $page_name, PDO::PARAM_STR); 
$page_name_get->execute(); 
if($page_name_get->rowCount() > 0) {
$row = $page_name_get->fetch(PDO::FETCH_ASSOC);
$menu_type = $row['menu_type'];
switch($menu_type) {
  case 'wmenu': {
    $template_file = 'custom_page_w_menu';
    break;
  }
  case 'menu': {
    $template_file = 'custom_page_menu';
    break;
  } 
}
$collection->attachRoute(new PHPRouter\Route('/pages/'.$page_name.'', [
    '_controller' => 'App\Controllers\CustomPage::CustomPage',
    'methods' => ['POST','GET'],
    'parameters'=> ['template_file'=>$template_file],
]));
}
}

but i get a error:
Fatal error: Uncaught Error: Unknown named parameter $template_file in C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Route.php:200

Can you help me to fix it ?

commented

the full error is :

Fatal error: Uncaught Error: Unknown named parameter $template_file in C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Route.php:200 Stack trace: #0 C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Route.php(200): call_user_func_array(Array, Array) #1 C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Router.php(143): PHPRouter\Route->dispatch() #2 C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Router.php(89): PHPRouter\Router->match('/install.php', 'GET') #3 C:\xampp2\htdocs\core.php(386): PHPRouter\Router->matchCurrentRequest() #4 {main} thrown in C:\xampp2\htdocs\vendor\dannyvankooten\php-router\src\Route.php on line 200

on line 386 i have this:
$route = $router->matchCurrentRequest();

Hello,

That has is not an issue of the library...
Read carefuly and try to understand this library's documentation, if you need help coding your app please go to stackoverflow.

Thank you

commented

Ok, thank you.