router icon indicating copy to clipboard operation
router copied to clipboard

How to get the route from controller/action ?

Open FLasH3r opened this issue 4 years ago • 1 comments

I want to output a menu and get the links automatically from the router.

<a href="/">Home</a>
<a href="/contact_us">Contact Us</a>

But I don't want to write the url in the html manually.

If I set this:

$router->get('/', 'Controller@home');
$router->get('/contact_us', 'Controller@contact');

How can I get / back from Controller class, index method? How can I get /contact_us back from Controller class, contact method?

FLasH3r avatar Mar 23 '21 19:03 FLasH3r

I'm working on a PR rn, so you can call other routes except 404. Your feature would be possible after hat merge, but it would need much more unnecessary performance every time you need a link. I recommend you to simply just write /contactus or something. These links should be static anyway

uvulpos avatar Apr 11 '21 11:04 uvulpos