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

davy_yg's avatar
Level 27

base url

Hello,

I want to add base url in laravel, how to do so?

value="{{ $image->img_name }}"

Add base url to the value

0 likes
12 replies
davy_yg's avatar
Level 27

Is URL::asset the same like public_html?

<link rel="stylesheet" href="{{ URL::asset('themes/style/add.css') }}" />
bestmomo's avatar

public_html is your server directory, helper will work if your domain points well on this folder.

davy_yg's avatar
Level 27

What this mean:

URL::asset('themes/style/add.css')

Which exact folder does it refer to?

towhid's avatar

@@davy_yg please try this process

if you want to change your base url then open your .ENV file and change your code

APP_URL=http://localhost

to 

APP_URL= ? which one you want your base url  link  // example APP_URL = http://towhid.localhost

for this base url u must be use document root process follow if you want xamp server then follow this code

https://www.cloudways.com/blog/configure-virtual-host-on-windows-10-for-wordpress/

    <VirtualHost *:80>
    DocumentRoot "c:/xampp/htdocs/laravel/laravel-one"
    ServerName towhid.localhost
    <Directory "c:/xampp/htdocs/laravel/laravel-one">
    </Directory>
    </VirtualHost>
#
127.0.0.1 localhost
::1 localhost

127.0.0.1      towhid.localhost

after this procedure complete you must be restert your server local then you can get your base url this syntax

{{url('/')}} http://towhid.localhost

$url = url('/') // http://towhid.localhost

rawilk's avatar

@towhid That APP_URL is mostly for the console, tests and emails.

@davy_yg Are you serious? The documentation is right here... https://laravel.com/docs/5.8/urls

You can see the value if outputs by looking at the page source or doing a simple dd. I mean come on, this is just simple debugging and reading documentation...

2 likes
Jaytee's avatar

Start looking at the documentation for once Davy. You've been asking bullshit questions for nearly a year and a half now, on everything that is in the documentation, or on the first page in Google. Are you actually going to learn how to code at some point, or are you just gonna milk Laracasts for the answers?

The point of this forum is to help people, yes, but not to help people who can't even consult the documentation, and ask questions multiple times per week, to which the answers can be found in seconds.

1 like
esmaill23's avatar
{{ asset('images/'.$image->img_name) }}

this refer to public/images/ folder and image in it .

towhid's avatar

@JLRDW - i think this is use only for

assests call like css, image and js

asset('')

action time / href / or url call

url('') 

naming time only

route('')
jlrdw's avatar
<img src="{{ asset('upload/imgdogs') . '/' . $row->dogpic }}" alt="" class="image">

Works perfect.

towhid's avatar

@davy_yg

why you want to use base url in your value ??

if you really want to use your base url in your value ... just use

{{url('/').$image->img_name}}

Please or to participate in this conversation.