flightphp / core

An extensible micro-framework for PHP
https://docs.flightphp.com
MIT License
2.63k stars 409 forks source link

Flight::group lacks nesting support for organizing routes hierarchically. Adding this feature will enhance route management flexibility. #589

Closed planework closed 4 months ago

planework commented 4 months ago

Flight::group('/api/v1', function () { echo "v2"; Flight::group('', function () { Flight::route('GET /data', function () { Flight::template()->render('call.index'); }); }); }); Flight::group('/api/v2', function () { echo "v2"; Flight::group('', function () { Flight::route('GET /data', function () { Flight::template()->render('call.index'); }); }); });

html: v2v2

n0nag0n commented 4 months ago

I guess I'm confused. It already supports nested groups, and it's tested to run that way. The reason why your v2v2 is showing up is because any output buffer into a group function is not captured (nor do I think it should be captured unless there's a good argument for it) because just listing out a group shouldn't immediately invoke some output.

Is that what you're asking for? Output buffering in a group context?

n0nag0n commented 4 months ago

Also, love the github username. Flight appreciates your support ;)

n0nag0n commented 4 months ago

Feel free to reopen this. Just closing it for now.