Comments (9)
It's not something that is planned for 2.0.0, however it may be something that we look at going forward.
from route.
Do you think that it is something that coule be implemented without to much effort?
If so, I will try if I can implement it myself :)
-------- Original Message --------
From: Phil Bennett [email protected]
Sent: Thursday, December 17, 2015 01:14 PM
To: thephpleague/route [email protected]
Subject: Re: [route] Nested route groups (#96)
CC: Eragon666 [email protected]
It's not something that is planned for 2.0.0, however it maybe be something that we look at going forward.
Reply to this email directly or view it on GitHub:
#96 (comment)
from route.
I think there is probably quite a large level of complexity at first look, the issue here is that a nested group can then have a nested group, then that nested group can have a nested group, so there are considerations to be made around that, it also will probably be required to be explicitly defined as a nested group so that it can inherit the parents prefix.
More than happy for you to have a go at it, then we'll look through it and address any complexities for the next feature release.
from route.
I will try to take a look at this feature in the Christmas holiday.
If you have any tips/recommendations or anything else please let me know!
And I will keep you updated in this issue ofcourse
from route.
👍
from route.
And if the group
method receive an array instead of a closure, as all mapping methods return a Route
object that can alter the path
attribute, the nesting can be done easily. eg.
$router->group('/admin', [
$router->get('/', '...'),
$router->group('/cms', [
$router->get('/posts', '...')
])
]);
PHP will first register /
and the inner /posts
, so the inner group will change the /posts
to /cms/posts
, and at the end the outer group will prefix all these routes passed as parameter with /admin
.
This idea is simple and needs a little refactoring, but will allow a big flexibility in registering routes. If accepted I could implement that and request a pull.
from route.
That would actually require an overhaul of the group system because using the closure, the routes are actually registered on the group object, not the router itself
from route.
We could work with a level indicator, similar to transaction nesting levels. But in this case I would prefer a NestedRouteGroup extending the RouteGroup
from route.
I feel like the benefit this provides isn't worth the complexity it introduced. For the example above I think a nicer way of handling it for readability would be to have multiple groups anyway.
from route.
Related Issues (20)
- Feature request: custom attributes for route and route group accessible within a middleware HOT 6
- Catch Exception Best Way HOT 3
- Feature request: map with array of methods HOT 1
- Feature request: make $request available in getOptionsCallable HOT 2
- I cannot make post requests HOT 5
- Url resolve fails with 2 numeric parameter HOT 3
- Add an option to get the target route from the middleware HOT 2
- Why isn't the middleware stack executed for unmatched routes? HOT 2
- psr/simple-cache version constraints HOT 2
- Allow for empty route paths to be treat as the base route path HOT 2
- Nested groups are required HOT 1
- Feature request: Treat Route `$handler` that implements RequestHandlerInterface as callable
- Root exception class (and possibly, its children) not compatible with PHP7+
- Request matcher? guess if ServerRequest can be handled
- Dispatcher: handle and find HOT 1
- Feature: Extra map() options
- Method to get declared routes?
- How can I assign controller to errors http ? HOT 1
- Cannot Change Cache Key
- Is this package still actively maintained? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from route.