Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot retrieve Route Parameters #1

Closed
edwardteach42 opened this issue Jan 18, 2017 · 2 comments
Closed

Cannot retrieve Route Parameters #1

edwardteach42 opened this issue Jan 18, 2017 · 2 comments

Comments

@edwardteach42
Copy link

edwardteach42 commented Jan 18, 2017

I am having trouble getting the route parameters using this boilerplate. Here is what I am doing:

Add to src/App/Resources/routes/app.php:

$app->get('/test/{testparam}', 'AppController:testParams')
    ->setName('test');

Add to src/App/Controller/AppController.php:

public function testParams($request, $response, $args) {
        echo $args['testparam'];
    }

Then go to: http://0.0.0.0:8888/test/thisistheparam and there you should see thisistheparam but instead there is an error and the first letter of the route parameter.

Warning: Illegal string offset 'testparam' in C:\Users\Jeff\Projects\test2\src\App\Controller\AppController.php on line 16
t
@awurth
Copy link
Owner

awurth commented Jan 18, 2017

This is because I changed Slim's route strategies to get the params as separate arguments instead of an array.

If you want the old behaviour, just remove these three lines at the end of bootstrap/dependencies.php:

$container['foundHandler'] = function() {
    return new \Slim\Handlers\Strategies\RequestResponseArgs();
};

For more infos, check out the Slim documentation:
https://www.slimframework.com/docs/objects/router.html#route-strategies

@edwardteach42
Copy link
Author

Thanks, that was the solution. I need to stop coding at 3am.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants