0

I did not find anything related to Lumen (not Laravel) for passing value to controller. Is my approach wrong or am I just missing the obvious ?

I want to pass a parameter to controller, not talking about the {name} in localhost:8000/someprefix/{name}. As lumen is using FastRoute and I do not want to change back to default router. I want to pass value to the controller as method parameter ? Any help will be appreciated.

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;
}
Naveen Niraula
  • 771
  • 10
  • 19
  • Can you describe your purpose a little bit more? Why you're not defining a global variable or add new environment variable? – Tuğca Eker Apr 20 '18 at 11:24
  • I'm creating an API ( like you don't already know :p ). I just want to pass what kind of request it is `['POST','PUT','PATCH']` etc and return an JSON response including the response something like `{'request_method': 'POST'}` but extracted from passed parameter. – Naveen Niraula Apr 20 '18 at 11:39

0 Answers0