Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

themate0's avatar

get path by route name

Hi, i like to name my routes and then in view get urls by calling route('route.name') but this function is giving me whole url and i would like only to get the path like:

Using function: route('foo.bar')

I want to get: foo/bar

instead: http://acme.io/foo/bar

hope you get my point

0 likes
3 replies
Cronix's avatar

Can you explain a bit about why, and where you'd need to do this? There are ways to get that but it depends... so need a bit more info. Do you need to get it from a request object, or ?

themate0's avatar

Uh, thanks you for fast answer, i read on stackoverflow how to solve it I just need to add false as third parameter to get only url path.

I am using route function in forms, a href links etc. I find it ugly to have links on my site with whole url insteand just path to resource.

Topic can be closed.

Cronix's avatar

I find it ugly to have links on my site with whole url insteand just path to resource.

That's kinda funny lol

Please or to participate in this conversation.