Skip to content
Advertisement

Laravel: Get base URL

Simple question, but the answer seems quite hard to come by. In Codeigniter, I could load the URL helper and then simply do

JavaScript

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

Advertisement

Answer

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

So you can do:

JavaScript

You can also use the application container:

JavaScript

Or inject the UrlGenerator:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement