如何在FastRoute中将参数传递给控制器​​?

时间:2018-04-20 11:16:29

标签: php regex lumen fastroute

我没有找到与 Lumen (非Laravel)相关的任何内容,因为它将值传递给控制器​​。我的方法是错误的还是我错过了明显的方法?

我想将参数传递给控制器​​,而不是在{name}中讨论localhost:8000/someprefix/{name}。由于流明使用 FastRoute ,我不想更改回默认路由器。我想将值作为方法参数传递给控制器​​?任何帮助将不胜感激。

web.php

// $value has the method
// I want to pass the $myParameter value to below mentioned statement ?
// and receive it as parameter in **methodNotAllowedHere()** in the controller
$myParameter = 10;
$router->addRoute($value, '/signup', 'UserController@methodNotAllowedHere');

UserController.php

// i want to receive $myParameter as  $value 
public function methodNotAllowedHere( $value = '' ) {
    return $value;
}

0 个答案:

没有答案
相关问题