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

Implement URI generation for named routes #277

Merged
merged 10 commits into from
Mar 4, 2024
Merged

Conversation

lcobucci
Copy link
Collaborator

@lcobucci lcobucci commented Feb 6, 2024

Fixes #139
Fixes #66

This is an alternative implementation for #270, leveraging extra parameters for configuring things instead of following conventions around the handler.

The route generation process is a copy of https://github.com/mezzio/mezzio-fastroute/blob/3.12.x/src/FastRouteRouter.php#L248 (created by @weierophinney) with minor changes.

I still need to:

  • Add more tests
  • Provide better exceptions
  • Add benchmarks
  • Verify whether or not it makes sense to provide that functionality for static routes

The main arguments for following this approach are:

  1. Not mixing handlers and route names, allowing people to also generate URIs when using callables
  2. Providing validations for the substitution arguments
  3. Trading data generation performance for URI generation performance

Lock file operations: 0 installs, 2 updates, 0 removals
  - Upgrading phpstan/phpstan (1.10.57 => 1.10.58)
  - Upgrading seld/jsonlint (1.10.1 => 1.10.2)

Signed-off-by: Luís Cobucci <[email protected]>
This allows us to reuse that parameters to introduce the URI generation
component.

Signed-off-by: Luís Cobucci <[email protected]>
This allows users to easily handle exceptions coming from this library.

Signed-off-by: Luís Cobucci <[email protected]>
This introduces the ability to create URIs from the configured routes,
following the same semantics of route dispatching when it comes to URL
encoding (it needs to be handled by the user of the library).

Signed-off-by: Luís Cobucci <[email protected]>
This allows them to evolve separately.

Signed-off-by: Luís Cobucci <[email protected]>
This enables the retrieval of named routes and URI generation from the
main library configuration.

Signed-off-by: Luís Cobucci <[email protected]>
Signed-off-by: Luís Cobucci <[email protected]>
@lcobucci lcobucci marked this pull request as ready for review March 4, 2024 23:44
@lcobucci lcobucci merged commit d3ada01 into master Mar 4, 2024
32 of 33 checks passed
@lcobucci lcobucci deleted the route-generation branch March 4, 2024 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reverse routing Route to URL generation / reverse routing
1 participant