Skip to content

Adding query parameters to URL route? #5

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

Closed
bradical1379 opened this issue Jan 7, 2021 · 1 comment
Closed

Adding query parameters to URL route? #5

bradical1379 opened this issue Jan 7, 2021 · 1 comment

Comments

@bradical1379
Copy link

Is it possible to pass additional query parameters on a route, and if so, how can we capture those parameters in tandem with the route parameters?

For example, if you have the route:

// search books
$router->get('/books/title/:title', 'Books@searchBooksByTitle');

Could append the URL to include some additional parameters like:

https://localhost/books/title/Harry?sort=publish_date

I am running into issues when I attempt that it says the requested route is not found, and I believe that is because its explicitly looking for a route to match with the query parameters on it.

afgprogrammer added a commit that referenced this issue Jan 8, 2021
@afgprogrammer
Copy link
Owner

@bradical1379 The issue is fixed. Now you can access your query params in the controllers:

$this->request->get('sort')

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