Search code examples
phplaravellaravel-5.5

get site name along with protocol in laravel


How can I get current site name with it's used protocol in laravel?

For example suppose user requested this :

https://example.com/some/path

I want to get https://example.com in a controller method.

Update:

I used ngrok service to access my localhost as a https random domain that it provieded and in all ways that suggested in answers returned main http://localhost


Solution

  • Use this:

    request()->root()