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

willpsng's avatar

help with Laravel URL helper function

Hey everyone, I'm having some trouble with the url() helper function.

It seems to always be using 'localhost' as the domain name, but I can't seem to figure out why that is. My app.php file is as follows:

'url' => env('APP_URL', 'journal.willng.me'),

and, the corresponding env variable is appropriately set (ie: not localhost). To further demonstrate, have a look at this screenshot of tinker. It pretty clearly describes my problem.

See what I mean? does the url() helper draw the domain from somewhere else?

0 likes
7 replies
ohffs's avatar

If you set the url parameter to the domain, does that work?

willpsng's avatar

@ohffs no dice, returns same result.

@bobbybouwmann the behaviour is observed in production as well (which is obviously on the domain) which is especially odd to me.

willpsng's avatar

Behaviour is even odder now: it works right in tinker, as you can see:

It also works when I echo url('something') in one of the views. But it still continues not to work in my email templates. I'm using a mail queue. Might this be affecting it?

kodemania's avatar

try this. set APP_URL in env file.

url (env('APP_URL'),'signup/activate'));

For me it works in email template and I was also facing same issue with queue and emails.

1 like
imansyaefulloh's avatar

you should close the tinker after you edit some code, and then run tinker again

Please or to participate in this conversation.