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

Using ? instead of / #103

Open
bnsd55 opened this issue Oct 17, 2016 · 3 comments
Open

Using ? instead of / #103

bnsd55 opened this issue Oct 17, 2016 · 3 comments

Comments

@bnsd55
Copy link

bnsd55 commented Oct 17, 2016

Hey,
I'm trying to add a route to my website with tools?p=K94rF pattern and not /tools/K94rF.
So i've written:
$router->get('/tools?p=:p_id', [ToolsController::class, 'actionGetTools'], [ 'require' => [ 'p_id' => '[a-zA-Z0-9_-]{5}', ], 'default' => [ 'p_id' => '', ] ]);

And it is not working, so i tried to change it from ? to /, like this:
$router->get('/tools/:p_id', [ToolsController::class, 'actionGetTools'], [ 'require' => [ 'p_id' => '[a-zA-Z0-9_-]{5}', ], 'default' => [ 'p_id' => '', ] ]);

And it works perfect.
I need the routing with ? (the first one), there is any other way to implement it ?

Thank you 😄

@c9s
Copy link
Owner

c9s commented Oct 18, 2016

Yes, you should use the second one.

The first one is not possible.

@bnsd55
Copy link
Author

bnsd55 commented Oct 18, 2016

The second one does not working

2016-10-18 15:38 GMT+03:00 Yo-An Lin [email protected]:

Yes, you should use the second one.

The first one is not possible.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#103 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ATRp6K9pRswHvwFB-fBm33l2dFQcczlhks5q1L3egaJpZM4KYrhe
.

@ddv88
Copy link

ddv88 commented Apr 19, 2017

You can do something like $mux->get("/search?:query", ["Controllers\\Index", "actionIndex"]);
And then use raw $_GET in your controller. $query = array_map("some_filtering_function", $_GET);

https://sitename.com/search?city=1&type=2
Array ( [city] => 1 [type] => 2 )

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

3 participants