Home >Backend Development >PHP Tutorial >How does Slim framework get the current url?
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
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