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

[11.x] Execute then Callback Before Loading web Routes in ApplicationBuilder #51545

Closed

Conversation

ahmedeladl00
Copy link

Summary

This pull request ensures that the then callback is executed before loading the web routes in the ApplicationBuilder. This change is necessary to prevent domain-specific routes from being overridden by the main web routes.

Rationale

In applications with domain-specific routing requirements, it is crucial that domain-specific routes are loaded before the general web routes to avoid conflicts. Executing the then callback before loading the web routes ensures that domain-specific routing logic is prioritized, improving maintainability and scalability.

Changes

  • The then callback is now executed before loading the web routes in the ApplicationBuilder::buildRoutingCallback method.

Testing

This change has been tested to ensure that domain-specific routes are correctly applied and that no existing functionality is broken. The following scenarios have been verified:

  • Domain-specific routes are loaded correctly.
  • General web routes are loaded correctly after domain-specific routes.
  • No conflicts or overrides occur between domain-specific and general routes.

Additional Notes

This change does not affect existing applications that do not use domain-specific routing. It enhances flexibility for those who do, adhering to Laravel's best practices for routing.

@crynobone
Copy link
Member

This feels like a breaking change as then implies it would run last.

@ahmedeladl00
Copy link
Author

ahmedeladl00 commented May 23, 2024

it worked with me as I have sub domains in my site and when i make a subdomain like that

then: function ($router) {
            Route::domain('blog.example.com')
                ->middleware('web')
                ->group(base_path('routes/blog.php'));
        }

and the blog has the same route (name) as in the web then the web route overrides it and it wouldn't called

@driesvints driesvints changed the title Execute then Callback Before Loading web Routes in ApplicationBuilder [11.x] Execute then Callback Before Loading web Routes in ApplicationBuilder May 23, 2024
@driesvints
Copy link
Member

This is a breaking change unfortunately. Please try master instead.

@driesvints driesvints closed this May 23, 2024
@ahmedeladl00 ahmedeladl00 deleted the improve-routing-callback branch May 23, 2024 08:30
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.

None yet

3 participants