Google News
logo
Slim Framework - Interview Questions
What is The Request URI in Slim Framework?
Every HTTP request has a URI that identifies the requested application resource. The HTTP request URI has several parts :
 
* Scheme (e.g. http or https)
* Host (e.g. example.com)
* Port (e.g. 80 or 443)
* Path (e.g. /users/1)
* Query string (e.g. sort=created&dir=asc)

You can fetch the PSR-7 Request object’s URI object with its getUri() method:
$uri = $request->getUri();
The PSR-7 Request object’s URI is itself an object that provides the following methods to inspect the HTTP request’s URL parts:
 
* getScheme()
* getAuthority()
* getUserInfo()
* getHost()
* getPort()
* getPath()
* getQuery() (returns the full query string, e.g. a=1&b=2)
* getFragment()

You can get the query parameters as an associative array on the Request object using getQueryParams().
Advertisement