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] Allow adding array or string for web and api routes in bootstrap/app.php #51356

Merged
merged 11 commits into from
May 13, 2024

Conversation

mrthito
Copy link
Contributor

@mrthito mrthito commented May 9, 2024

This PR is Resubmitted after Taylor feedback

This pull request proposes an enhancement to Laravel's bootstrap/app.php file, enabling developers to add routes in array format or as strings for both web and api route groups.

Motivation

The motivation behind this enhancement is to provide developers with greater flexibility and convenience when defining routes, particularly in scenarios where applications have different guards and need to create different routes for each guard rather than writing require/require_once in route file.

Use Cases

In projects where route management becomes complex due to the proliferation of routes or diverse authentication scenarios, this will simplifies the process by enabling developers to organize routes into multiple route files effortlessly. By allowing routes to be defined in array format, developers can easily create separate route files corresponding to different functionalities, user roles, or authentication guards. This approach promotes code organization and maintainability, as each route file can focus on a specific aspect of the application, making it easier to understand and manage.

Additional Context

I'm developing an ecommerce website with five different guards, and I want to include separate route files for each guard. Using require or require_once made my code look outdated, and I disliked it. Let's simplify by allowing arrays as well in the $web parameter of withRouting() method in Illuminate\Foundation\Application

carbon

@mrthito mrthito requested a review from PerryvanderMeer May 13, 2024 08:37
@driesvints
Copy link
Member

We'll have to revert this one unfortunately because of #51406

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.

4 participants