我使用这个路由器 - https://github.com/dannyvankooten/PHP-Router,如下所示:
$collection->attachRoute(new PHPRouter\Route('/install.php', [
'_controller' => 'App\Controllers\Install::Install',
'methods' => ['GET','POST'],
'parameters'=> ['template_file'=>'../../install/install'],
]));
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
$collection->attachRoute(new PHPRouter\Route('/install.php', [
'_controller' => 'App\Controllers\Install::Install',
'methods' => ['GET','POST'],
'parameters'=> ['template_file'=>'../../install/install'],
]));
Run Code Online (Sandbox Code Playgroud)
参数是我添加的,也许有问题...你能帮我吗?
在 core.php 的第 389 行我有这个:
$route = $router->matchCurrentRequest();
Run Code Online (Sandbox Code Playgroud)
在路线php上: https: //github.com/dannyvankooten/PHP-Router/blob/master/src/Route.php router.php: https: //github.com/dannyvankooten/PHP-Router/blob/master/src /路由器.php
请给我建议如何解决这个问题:)
Pil*_*lan 11
在 php8 中你已经命名了 argument。
https://github.com/dannyvankooten/PHP-Router/blob/master/src/Route.php#L184
Calls call_user_func_array,它接受参数作为数组。
在 php < 8 中,关联数组像普通索引数组一样使用,因为键没有任何意义。在 php8 中,键必须与函数的变量名称匹配。
为了让你的代码正常工作,你只需要去掉这些键:
$collection->attachRoute(new PHPRouter\Route('/ajax/dropzone', [
'_controller' => 'App\Controllers\Ajax\Dropzone::Dropzone',
'methods' => ['POST','GET'],
'parameters'=> ['template_file'=>'ajax'],
^---------------^ remove this.
]));
Run Code Online (Sandbox Code Playgroud)
例子。