zend-router icon indicating copy to clipboard operation
zend-router copied to clipboard

Router rewrite for PSR-7

Open Xerkus opened this issue 7 years ago • 4 comments

Work in progress

Goal of the rewrite is to switch component to the native support of PSR-7.

Console routing and http request routing are too different. Common interface proved to be limiting and of little practical value: routes were not shared between the two and consumers had to accept one and outright reject another in most cases. Next implementation of zend-mvc will be PSR-7 based as well and zend-mvc-console will be dropped.

For that reason, support for Zend\Http\RequestInterface will be dropped as too incompatible with PSR-7 and support for the non-http routing with Zend\Stdlib\RequestInterface will not be retained as impractical. Effectively that will make zend-router a PSR-7 only router.

Also, this PR bumps minimum php to 7.1, introduces strict types, scalar and return typehinting

Note: this PR is a subject for rebases and commit squashes. Ask before using as a basis for your work.

Xerkus avatar Nov 04 '17 03:11 Xerkus

Small note: I wanted to keep RouteMatch as a separate thing from RouteResult to keep it more or less backward compatible. It is used extensively in zend-mvc, but consumers should really be using PSR-7 request attributes for matched parameters. While it will cause additional migration challenges for zend-mvc users, it will be more in line with zend-expressive and the rest of the industry. Besides, attempts to keep RouteMatch and request attributes in sync are error prone and pretty much guaranteed to produce subtle bugs.

Xerkus avatar Nov 16 '17 07:11 Xerkus

Routes doing partial match conditionally and depending on the concrete implementation are violating RouteInterface contract. To make things more straightforward, RouteInterface is now not allowed to return partial match. PartialRouteInterface extending RouteInterface was introduced instead. Chain, Hostname, Literal, Method, Regex, Scheme and Segment are now partial routes. Chain was changed to accept partial routes only, Part was changed to accept only partial route for its base route.

Xerkus avatar Nov 16 '17 09:11 Xerkus

This repository has been closed and moved to laminas/laminas-router; a new issue has been opened at https://github.com/laminas/laminas-router/issues/6.

weierophinney avatar Dec 31 '19 22:12 weierophinney

This repository has been moved to laminas/laminas-router. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-router to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-router.
  • In your clone of laminas/laminas-router, commit the files, push to your fork, and open the new PR. We will be providing tooling via laminas/laminas-migration soon to help automate the process.

weierophinney avatar Dec 31 '19 22:12 weierophinney