Coder Social home page Coder Social logo

Comments (9)

philipobenito avatar philipobenito commented on July 22, 2024

It's not something that is planned for 2.0.0, however it may be something that we look at going forward.

from route.

matthijsthoolen avatar matthijsthoolen commented on July 22, 2024

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.

philipobenito avatar philipobenito commented on July 22, 2024

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.

matthijsthoolen avatar matthijsthoolen commented on July 22, 2024

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.

philipobenito avatar philipobenito commented on July 22, 2024

👍

from route.

alexrohleder avatar alexrohleder commented on July 22, 2024

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.

philipobenito avatar philipobenito commented on July 22, 2024

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.

mbunge avatar mbunge commented on July 22, 2024

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.

philipobenito avatar philipobenito commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.