本文整理匯總了PHP中Zend\Http\PhpEnvironment\Request::getBasePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::getBasePath方法的具體用法?PHP Request::getBasePath怎麽用?PHP Request::getBasePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::getBasePath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBasePathDetection
/**
* @dataProvider baseUrlAndPathProvider
* @param array $server
* @param string $baseUrl
* @param string $basePath
*/
public function testBasePathDetection(array $server, $baseUrl, $basePath)
{
$_SERVER = $server;
$request = new Request();
$this->assertEquals($baseUrl, $request->getBaseUrl());
$this->assertEquals($basePath, $request->getBasePath());
}
示例2: generateXml
/**
* Generate Xml
*
* @param array $documents Array with all documents
* @param Request $request Request
*
* @return string
*/
protected function generateXml($documents, Request $request)
{
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
$url = $request->getBasePath();
foreach ($documents as $document) {
$xml .= '<url>';
$xml .= '<loc><![CDATA[' . $url . $document->getUrl() . ']]></loc>';
$xml .= '<lastmod>' . date('Y-m-d\\TH:i:s\\Z', strtotime($document->getUpdatedAt())) . '</lastmod>';
$xml .= '<changefreq>weekly</changefreq>';
$xml .= '<priority>0.5</priority>';
$xml .= '</url>';
}
$xml .= '</urlset>';
return $xml;
}
示例3: _getRelativePath
/**
* Get the URI path of the request, relative to the application base URL.
*
* @param HttpRequest $request
* @return string
*/
protected function _getRelativePath(HttpRequest $request)
{
$basePath = $request->getBasePath();
$relPath = $request->getUri()->getPath();
if (!empty($basePath) && strpos($relPath, $basePath) === 0) {
$relPath = substr($relPath, strlen($basePath));
}
return $relPath;
}
示例4: getBasePath
/**
* Gets the base path.
*
* @return string The base path
*/
public function getBasePath()
{
return $this->request->getBasePath();
}