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

Unify Router use #28

Merged
merged 1 commit into from
Apr 27, 2023
Merged

Unify Router use #28

merged 1 commit into from
Apr 27, 2023

Conversation

antonio-gg-dev
Copy link
Member

📚 Description

I think that since the Router became instantiable and it was possible to be configured multiple times, our use of the Router API became somewhat more complex. On the one hand, you could create, configure, and execute the Router statically only using Router::configure(), and on the other hand, you could create an instance, configure, and execute it by consecutively calling Router::create(), $router->addRoutes(), and $router->run().

All of this seems to me to add an extra layer of complexity that could be resolved simply by offering a new non-static method of operation. By doing less for the user and following the KISS principle, the fewer public methods we expose, the simpler it will be for developers to use our API. Therefore, it would be easier to use, although this would force anyone who wants to use the "old static method" to instantiate a router, configure it, and execute it.

In addition, the method for configuring the router instance is called addRoutes(), a name that I don't think is entirely appropriate, since it not only serves to add Routes but also Handlers and Dependencies, which I believe makes it even more difficult to use.

This PR is just a proposal for how I think everything could be simplified. Feel free to open up a debate, propose alternatives, make changes...

Copy link
Member

@Chemaclass Chemaclass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KISS FTW!

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.

3 participants