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

Issue with action parameters #61

Open
Dripnix opened this issue Jun 10, 2020 · 1 comment
Open

Issue with action parameters #61

Dripnix opened this issue Jun 10, 2020 · 1 comment

Comments

@Dripnix
Copy link

Dripnix commented Jun 10, 2020

Hello thank you for your awesome framework.
However I am at loss on how to add parameters after the action.
What I wish to accomplish is this:

/controller/action/id such example as /contacts/index/5 to read contact with id 5

Every iteration i do gives error on Router.php
I have added this $router->add('{controller}/{action}/{id:\d+}'); to the routes but not doing anything.

@daveh
Copy link
Owner

daveh commented Jun 10, 2020

Do you get an error when you use that route? If so, what does it say?

That route looks fine - if you have that route, with the URL /contacts/index/5, the framework will run the indexAction method in the Contacts controller. The ID from the route will be available in the route_params property of the current controller, e.g.

public function indexAction()
{
    $id = $this->route_params['id'];
}

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