PHP-Router
PHP-Router copied to clipboard
Controller method with custom params (ids parameters excluded) throw Too few arguments Exception
- PHPRouter version: @dev-master
- PHP version:
- Exact steps to cause this issue
- Create abstraction of router.
- Create controllers with customs params and at first the id, and load routes.
- Sending request.
- What you expected
- e.g. I expected to get my custom params with the id.
- What happened instead
- e.g. Instead, I got Error : Too few arguments to function Controller::test(), 1 passed and exactly 2.
Hey ! just found an exception about controllers method params. I wanted to pass (with or without url dynamic param) some custom object like a RequestObject.
To fix it, in Router.php, match() function, just before call $routes->setParameters($params);, add
foreach ($routes->getParameters() as $parameter) {
$params[] = $parameter;
}
Thanks you.