How to get base url in laravel using php

0 votes

In Codeigniter, I could load the url helper and then simply do

echo base_url();

to get my site's URL. Is there an equivalent in Laravel?

Sep 17, 2020 in PHP by kartik
• 37,520 points
17,095 views

1 answer to this question.

0 votes

Hello @kartik,

You can use the URL facade which lets you do calls to the URL generator

So you can do:

URL::to('/');

You can also use the application container:

$app->make('url')->to('/');
$app['url']->to('/');
App::make('url')->to('/');

Hope it helps!!

Thank YoU!!

answered Sep 17, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
1 answer

How to Get the full URL in PHP?

Hello @kartik, Have a look at $_SERVER['REQUEST_URI'], i.e. $actual_link = ...READ MORE

answered Sep 16, 2020 in PHP by Niroj
• 82,840 points
3,356 views
0 votes
1 answer

How to GET URL parameter in PHP?

Hello @kartik, $_GET is not a function or language ...READ MORE

answered Sep 17, 2020 in PHP by Niroj
• 82,840 points
3,926 views
0 votes
1 answer

How to get response using cURL in PHP?

Hello @kartik, Use the below piece of code ...READ MORE

answered Oct 19, 2020 in PHP by Niroj
• 82,840 points
7,079 views
0 votes
1 answer

How to get the list of specific files in a directory using php?

Hello @kartik, You'll be wanting to use glob() Example: $files = ...READ MORE

answered Nov 6, 2020 in PHP by Niroj
• 82,840 points
2,256 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,080 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
3,016 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,948 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,886 views
0 votes
1 answer

How to get the base domain/url in php?

Hello @kartik, Use SERVER_NAME. echo $_SERVER['SERVER_NAME'] ...READ MORE

answered Nov 3, 2020 in PHP by Niroj
• 82,840 points
12,577 views
0 votes
1 answer

How to get current URL path in PHP?

Hello @kartik, Use $_SERVER['REQUEST_URI'].  The URI which was given in ...READ MORE

answered Sep 1, 2020 in PHP by Niroj
• 82,840 points
4,041 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP