Hey,
take a look at the examples:
echo public_path();
// C:\Users\JohnDoe\laravel\public
vs
echo url('/');
// http://localhost/laravel/public
My browsers do not like the path that public_path() returns. Why does it return a file path instead of a URI? What can I do to fix this? Always use url('/') instead?
The public_path() function does not intend to be use to serve browser friendly uri, so you're right, you should use url('/') instead.
It returns the absolute path because you might need some way to return that path if you're handling files on the server that can also be accessed publicly...something like PDFs. As codextends said, just use the url helper.
Okay thanks! I wasn't really aware of it.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community