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

Light routes #37

Closed
xepozz opened this issue Mar 19, 2020 · 2 comments · Fixed by #125
Closed

Light routes #37

xepozz opened this issue Mar 19, 2020 · 2 comments · Fixed by #125
Assignees
Labels
status:ready for adoption Feel free to implement this issue.

Comments

@xepozz
Copy link
Contributor

xepozz commented Mar 19, 2020

Problems

I see errors in the implementation of Route:

  • The Route contains a container.
  • Route process the Request themselves, i.e. in addition to providing information, they also process it.

What the problems do they make?

  • It would seem that having a collection of Route's, it is possible to "dump" (var_dump or other), but this will not work with the current implementation, because the Container will be dumped, in which there are links to the same Route and everything will be repeated in recursion.
  • There is no single point of processing Routes. Each Route is independent, but treats itself equally.

Solution

I suggest:

  • Return RouterInterface and make an independent Router
  • Remove container from Routes
  • Remove Request processing from Route
  • Process all Routes in the Router
  • All middlewars will be initialized in Router too

Current workflow:

$route = new Route('GET', 'home/index');
$response = $route->handle($request);

Working with routes:

Future workflow:

$route1 = new Route('GET', 'home/index');
$route2 = new Route('POST', 'home/index');

$router = new Router($routes); 
// or
$router = $container->get(RouterInterface);
$router->injectRoutes($routes);
// or other ways to create the Router

$response = $router->handle($request);

Conclusion

  • Now Route can be "dumped", exported or cached very easly.
  • Route "knows" no more than what it needs to know. Now it's just a DTO
  • A single point of processing all requests (the Router). It gives:
       - The controlled process of matching any routes
       - Now you can implement the storage of the current route being processed
       - Other minor
@samdark
Copy link
Member

samdark commented Nov 4, 2021

Decided not to do it for now. May solve debugging issue with __debugInfo().

@samdark samdark added status:ready for adoption Feel free to implement this issue. and removed status:under discussion labels Nov 4, 2021
@samdark
Copy link
Member

samdark commented Nov 4, 2021

TODO:

  • Implement __debugInfo().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants