本文整理汇总了PHP中RequestHandler::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::factory方法的具体用法?PHP RequestHandler::factory怎么用?PHP RequestHandler::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: define
$appDir = '../app';
define('APP_PATH', realpath($appDir));
$vendorDir = '../vendor';
define('VENDOR_PATH', realpath($vendorDir));
$tmpDir = '../tmp';
define('TMP_PATH', realpath($tmpDir));
$jsControllersDir = 'assets/js/controllers';
define('JS_CONTROLLER_PATH', realpath($jsControllersDir));
require_once APP_PATH . '/env.php';
require_once APP_PATH . '/bootstrap.php';
// end: bootstrap the application
// get URL for processing
$url = isset($_GET['r']) ? trim($_GET['r'], '/') : '';
if (ENVIRONMENT == 'dev') {
// In the development environment all errors will be shown
RequestHandler::factory($container, $url)->run();
} else {
// In the production environment error pages will be shown instead
try {
RequestHandler::factory($container, $url)->run();
} catch (DBException $ex1) {
header($_SERVER["SERVER_PROTOCOL"] . ' 500 Internal server error');
echo $container->getTwig()->render('500.html', array());
} catch (UrlNotFoundException $ex2) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo $container->getTwig()->render('404.html', array());
} catch (NotFoundException $ex3) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo $container->getTwig()->render('404.html', array());
}
}
示例2: testRequestHandlerRunController
public function testRequestHandlerRunController()
{
$requestHandler = RequestHandler::factory($this->container, '/');
$requestHandler->run();
}