Home  >  Article  >  Backend Development  >  How does Slim framework get the current url?

How does Slim framework get the current url?

WBOY
WBOYOriginal
2016-08-30 09:36:441250browse

1. During the process of building the code, you need to obtain the current website domain name, which is similar to the base_url() function in CI
2. I searched the documentation and did not see any similar functions available
3. Because there is no I really want to try the SERVER global variable that comes with PHP to get the current domain name,
So I want to ask if Slim provides such a function

Reply content:

1. During the process of building the code, you need to obtain the current website domain name, which is similar to the base_url() function in CI
2. I searched the documentation and did not see any similar functions available
3. Because there is no I really want to try the SERVER global variable that comes with PHP to get the current domain name,
So I want to ask if Slim provides such a function

Yes.

<code class="php">$request->getUri()->getBaseUrl()</code>

getUri This method will return a Uri object, the class is under Http, you can take a look

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Oauth2 related issuesNext article:Oauth2 related issues