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

[Question] How to pass Custom Parameters inside URL #3

Closed
cstayyab opened this issue Sep 3, 2020 · 2 comments · May be fixed by #4
Closed

[Question] How to pass Custom Parameters inside URL #3

cstayyab opened this issue Sep 3, 2020 · 2 comments · May be fixed by #4
Assignees

Comments

@cstayyab
Copy link

cstayyab commented Sep 3, 2020

Hi!

I have read code and documentation provided but I couldn't find a way to pass parameters like we do in express.js. Yeah I did find a way to pass "hash" and numeric "id" but not a custom parameter.

$app.get('/user/:username', function ($req, $res) {
   $res->send($req->params['username']);
}

Is there a way to do that in php-express?

@cstayyab cstayyab changed the title [Question] How to pass Parameters inside URL [Question] How to pass Custom Parameters inside URL Sep 4, 2020
@Meleeman01
Copy link

https://github.com/riverside/php-express/blob/master/src/Request.php#L14 it should be possible to pass query parameters, i didn't write this and i just stumbled upon this gem. in theory you could write the functionality in here, definetely doable. although i'm not exactly sure what you mean by parameters.

@riverside
Copy link
Owner

I just commit a fix that address this issue. Application and Router now have a new method 'param'. You can use it like this:
https://riverside.github.io/php-express/api.html#app-param
https://riverside.github.io/php-express/api.html#router-param

@riverside riverside self-assigned this May 20, 2021
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

Successfully merging a pull request may close this issue.

3 participants