本文整理匯總了PHP中HTTPRequest::requestURI方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTPRequest::requestURI方法的具體用法?PHP HTTPRequest::requestURI怎麽用?PHP HTTPRequest::requestURI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::requestURI方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getController
/**
* Get the back controller matching with the HTTP request.
* @return BackController The controller.
*/
public function getController()
{
$router = $this->router();
$requestURI = $this->httpRequest->requestURI();
$websiteConfigFile = new Config(__DIR__ . '/../etc/core/website.json');
$websiteConfig = $websiteConfigFile->read();
$requestURI = preg_replace('#^' . preg_quote($websiteConfig['root']) . '#', '$1', $requestURI);
try {
//Let's get the route matching with the URL
$matchedRoute = $router->getRouteFromUrl($requestURI);
} catch (\RuntimeException $e) {
if ($e->getCode() == Router::NO_ROUTE) {
//No route matching, the page doesn't exist
$this->httpResponse->redirect404($this);
return;
}
}
//Add variables to the $_GET array
$_GET = array_merge($_GET, $matchedRoute->vars());
//And then create the controller
return $this->buildController($matchedRoute->module(), $matchedRoute->action());
}