本文整理汇总了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());
}