本文整理汇总了PHP中Zend_Application::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Application::run方法的具体用法?PHP Zend_Application::run怎么用?PHP Zend_Application::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Application
的用法示例。
在下文中一共展示了Zend_Application::run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRequest
public function doRequest($request)
{
// redirector should not exit
$redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
// json helper should not exit
$json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$zendRequest = new \Zend_Controller_Request_HttpTestCase();
$zendRequest->setMethod($request->getMethod());
$zendRequest->setCookies($request->getCookies());
$zendRequest->setParams($request->getParameters());
// Sf2's BrowserKit does not distinguish between GET, POST, PUT etc.,
// so we set all parameters in ZF's request here to not break apps
// relying on $request->getPost()
$zendRequest->setPost($request->getParameters());
$zendRequest->setRawBody($request->getContent());
$zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
$zendRequest->setHeaders($this->extractHeaders($request));
$_FILES = $this->remapFiles($request->getFiles());
$_SERVER = array_merge($_SERVER, $request->getServer());
$zendResponse = new \Zend_Controller_Response_HttpTestCase();
$this->front->setRequest($zendRequest)->setResponse($zendResponse);
ob_start();
try {
$this->bootstrap->run();
} catch (\Exception $e) {
ob_end_clean();
throw $e;
}
ob_end_clean();
$this->zendRequest = $zendRequest;
$response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse));
return $response;
}
示例2: doRequest
public function doRequest($request)
{
// redirector should not exit
$redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
// json helper should not exit
$json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$zendRequest = new \Zend_Controller_Request_HttpTestCase();
$zendRequest->setMethod($request->getMethod());
$zendRequest->setCookies($request->getCookies());
$zendRequest->setParams($request->getParameters());
$zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
$zendRequest->setHeaders($request->getServer());
$_FILES = $request->getFiles();
$_SERVER = array_merge($_SERVER, $request->getServer());
$zendResponse = new \Zend_Controller_Response_HttpTestCase();
$this->front->setRequest($zendRequest)->setResponse($zendResponse);
ob_start();
$this->bootstrap->run();
ob_end_clean();
$this->zendRequest = $zendRequest;
$response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $zendResponse->getHeaders());
return $response;
}
示例3: run
/**
* Display the generic error page for all otherwise-uncaught exceptions.
*/
public function run()
{
try {
return parent::run();
} catch (Exception $e) {
$this->_displayErrorPage($e);
exit;
}
}
示例4: doRequest
public function doRequest($request)
{
// redirector should not exit
$redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
// json helper should not exit
$json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
$zendRequest = new \Zend_Controller_Request_HttpTestCase();
$zendRequest->setMethod($request->getMethod());
$zendRequest->setCookies($request->getCookies());
//$zendRequest->setParams($request->getParameters());
if (strtoupper($request->getMethod()) == 'GET') {
$_GET = $this->remapRequestParameters($request->getParameters());
}
if (strtoupper($request->getMethod()) == 'POST') {
$_POST = $this->remapRequestParameters($request->getParameters());
}
$zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
$zendRequest->setHeaders($request->getServer());
$_FILES = $this->remapFiles($request->getFiles());
// это нужно для нормальной работы SE
$_SERVER['HTTP_HOST'] = str_replace('http://', '', $this->host);
if (isset($_SERVER['HTTP_REFERER'])) {
$_SERVER['HTTP_REFERER'] = str_replace('http://localhost', '', $_SERVER['HTTP_REFERER']);
}
//$_SERVER['SERVER_SOFTWARE'] = '';
$_SERVER['REQUEST_METHOD'] = strtoupper($request->getMethod());
$_SERVER['REQUEST_URI'] = str_replace('http://localhost', '', $request->getUri());
$zendResponse = new \Zend_Controller_Response_Http();
$this->bootstrap->getBootstrap()->getContainer()->frontcontroller->setRequest($zendRequest)->setResponse($zendResponse);
ob_start();
$this->bootstrap->run();
ob_end_clean();
$this->zendRequest = $zendRequest;
$headers['Content-type'] = "text/html; charset=UTF-8";
$response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $headers);
return $response;
}
示例5: defined
// Define application environment
/** @noinspection PhpConstantReassignmentInspection */
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production');
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(APPLICATION_PATH, realpath(APPLICATION_PATH . '/../vendor/zendframework/zendframework1/library'), get_include_path())));
/** @noinspection PhpIncludeInspection */
require_once '../vendor/autoload.php';
// require_once '../library/Zend/Loader/AutoloaderFactory.php';
// require_once '../library/Zend/Loader/ClassMapAutoloader.php';
Zend_Loader_AutoloaderFactory::factory(array('Zend_Loader_StandardAutoloader' => array('prefixes' => array('Zend' => realpath(__DIR__ . '/../vendor/zendframework/zendframework1/library/Zend'), 'application' => APPLICATION_PATH), 'fallback_autoloader' => true)));
/** Zend_Application */
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap();
$application->run();
} catch (Exception $e) {
try {
$guid = Dfi_Error_Report::saveException($e);
} catch (Exception $e) {
$guid = false;
}
if (APPLICATION_ENV != 'development') {
$url = "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s://" : "://") . $_SERVER['HTTP_HOST'] . '/';
header("Location: " . $url . "error/error" . ($guid ? '/guid/' . $guid : ''));
exit;
} else {
echo '<pre>REPORT: ' . ($guid ? $guid : 'brak') . "\n";
echo 'REQUEST: ' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "\n";
echo 'REFERER: ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . "\n";
echo 'ERROR: ' . $e->getMessage() . ' : ' . $e->getFile() . ' : (' . $e->getLine() . ')' . "\n" . $e->getTraceAsString() . '</pre>';