steampixel / simplePHPRouter

This is a simple and small single class PHP router that can handel the whole url routing for your project.
MIT License
406 stars 117 forks source link

all routes should return the full url of the page and its title #58

Closed kvvaradha closed 2 years ago

kvvaradha commented 2 years ago

With help of allroutes code, we need to get the entire list of routes with its full url and name or title of the page. If we pass additional parameter title to the Route:: add and get it working with name of the link, which is fine to organize them.

steampixel commented 2 years ago

You cannot get the "url" or "link" of all routes because it just does not exist inside the data. For example the route /user/([0-9]*)/edit can have the url /user/7/edit and also the url /user/4/edit. You cannot convert this pattern to a link.

Instead you should have an array or a database table holding your navigation entries. You can use this for generating menus. But routes and URLs are two different things. A router is not a link or navigation generator.

kvvaradha commented 2 years ago

Not all routes dude, some the main routes like few main pages might we have, that's only we can save it with a page title. and re call them when we prepare the menu and current page highlight options.

steampixel commented 2 years ago

!??! I still don't get it. Please try to create complete sentences.

ghost commented 2 years ago

THere is no use for that since you always route part of your output ready (ex: /user/([0-9]*)/edit). but if you still want to know the complete url, a basic php code like this should work:

$url = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];