Skip to content

Conversation

lonnieezell
Copy link
Member

Description

This allows users to choose which type of routing they want to use - auto routing or defined routing, and turn the other one completely off. This is especially beneficial if you're using auto-routing exclusively because it previously loaded up the entire route collection anyway and dealt with that overhead, even if it was empty.

Estimated performance increases:

  • auto-routing only: 4.5-15ms per request
  • defined routes only: 0.15 - 0.2ms per request

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@lonnieezell lonnieezell added enhancement PRs that improve existing functionalities 4.7 labels Oct 7, 2025
@neznaika0
Copy link
Contributor

is it possible to do inheritance? get rid of the conditions?

nothing like that:

if ($definedRoutes) new DefinedRoutesRouter();
else new Router();

This is an assumption, it may not work.

@lonnieezell
Copy link
Member Author

is it possible to do inheritance? get rid of the conditions?

nothing like that:

if ($definedRoutes) new DefinedRoutesRouter();
else new Router();

This is an assumption, it may not work.

Well, this was an attempt to do that to some extent, but the AutoRouter relies on the defined routes to ensure that any controllers used in defined routes can't be auto-routed. My preference would have been to separate them completely and have auto-router checked first, ignoring the defined routes. Then, if no route is matched it would move to checking defined routes. That would be nice and clean, but would also be a pretty big breaking change, and a potentially problematic one for lots of sites. So I did it this way hoping to keep things working for all sites as it does now.

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

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

Saved time with Auto Routing is nice - that's a useful enhancement.

Most of the suppressed PHPStan errors don't seem related to your code changes. I think it's time to sync the 4.7 branch with develop. I'll try to do that tomorrow.

@lonnieezell lonnieezell force-pushed the routing-options branch 2 times, most recently from 5de0a16 to 40e9309 Compare October 10, 2025 21:36
@michalsn
Copy link
Member

It looks like there are commits from a different PR included here. Could you please rebase and make sure only the commits relevant to this PR are included?

@lonnieezell
Copy link
Member Author

It looks like there are commits from a different PR included here. Could you please rebase and make sure only the commits relevant to this PR are included?

@michalsn Which commits? I did pull down the latest 4.7 and rebased last night. Then cs-fix and rector.

@michalsn
Copy link
Member

@lonnieezell this one:

"refactor(app): Standardize subdomain detection logic"

This is clearly a commit from a different PR. We should not see these changes here. However, I'm not sure what happened.

You can try:

git rebase --onto upstream/4.7 675dfef
// and then
git push --force-with-lease origin routing-options

@lonnieezell
Copy link
Member Author

ok, this is a mess and I managed to lose some of the original code. I'm closing for now and will revisit later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.7 enhancement PRs that improve existing functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants