Skip to content

Conversation

@ibnsultan
Copy link
Member

feat: add param values to request() params

What kind of change does this PR introduce? (pls check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe below

Description

This PR enhances the findRoute method to properly extract and merge dynamic route parameters into the $_GET superglobal. Previously, dynamic parameters were not accessible via request handlers if query parameters were present in the URL. This update ensures:

  • Dynamic parameters ({param}) in the route pattern are captured and assigned to $_GET.
    i.e the parameter value for a route like /user/{id} will also be available as $_GET['id'] or request()->params('id).
  • Query string parameters remain intact and merge seamlessly with route parameters.
  • Parameters with special characters (/) are trimmed correctly.
  • Route-matching logic is more robust and now supports indexed parameter handling (varN for unnamed segments).

This improvement provides better consistency for accessing request parameters within route handlers.

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

@ibnsultan ibnsultan requested a review from mychidarko March 21, 2025 12:51
@ibnsultan ibnsultan merged commit 6eeb39e into leafsphp:v4.x Mar 25, 2025
18 checks passed
@mychidarko
Copy link
Member

This is breaking regular request params and some middleware. Will be reverting

@ibnsultan
Copy link
Member Author

sure sure, will review where what wrong

@ibnsultan
Copy link
Member Author

ibnsultan commented Mar 31, 2025

This is breaking regular request params and some middleware. Will be reverting

@mychidarko I think i know the issue, i made the changes on a much older release and pushed it from there, could be that what is causing the issues

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 this pull request may close these issues.

2 participants