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

How can i use Query Parameters? #24

Open
yahoothemes opened this issue Jul 16, 2023 · 1 comment
Open

How can i use Query Parameters? #24

yahoothemes opened this issue Jul 16, 2023 · 1 comment

Comments

@yahoothemes
Copy link

Hi,
I have a search function by product name for example, and I call the server by ajax. The path is in the form like this. example.net/?q=orange. I have tried but only return Route not found error.
Can you tell me, how can I route with Query Parameters?
Thank you.

@gigili
Copy link
Owner

gigili commented Aug 22, 2024

Apologies for such a delayed response

I'm not sure how it slipped through the cracks.

If you're still having this problem, I'd be more than happy to assist you.

Using query parameters should be fully supported in the routing system.

You can handle them with a route configuration like this:

$route->get('/', function(Request $request) { 
    echo $request->get('q'); 
});

$route->get('/ajaxSearch', function(Request $request) { 
    echo $request->get('q'); 
});

You can then test these routes using URLs like:

https://example.com?q=test
https://example.com/ajaxSearch?q=test

Again, I apologize for the late response and any inconvenience it may have caused.

If there's anything else you'd like to discuss or if you still need help, please feel free to reach out. I'm here to help!

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