本文整理匯總了PHP中Library\Application::handle方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::handle方法的具體用法?PHP Application::handle怎麽用?PHP Application::handle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Library\Application
的用法示例。
在下文中一共展示了Application::handle方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dirname
const PROJECT_DIR = '..';
include dirname(__FILE__) . '/Loader.php';
$loader = new Loader();
/** 注冊命名空間目錄 */
$loader->registerNamespace(['Library' => PROJECT_DIR . '/library', 'Api\\Controller' => PROJECT_DIR . '/apps/controller']);
try {
$config = (require_once PROJECT_DIR . '/public/config.php');
$di = new DiContainer();
$di->set('logger', function ($logName = 'app.txt') use($config) {
return new Logger($config['log']['dir'] . $logName);
});
//重新設置view組件
$di->set('template', function () use($di) {
$compiler = $di->get('compiler');
$template = new \Library\Mvc\TemplateImpl\Template($compiler);
$template->setConfig(['templateDir' => PROJECT_DIR . '/apps/view/', 'compiledDir' => PROJECT_DIR . '/apps/cache/', 'debug' => true]);
return $template;
});
$di->set('dispatcher', function () {
$dispatcher = new \Library\Dispatcher();
$dispatcher->setDefaultNamespace('Api\\Controller');
return $dispatcher;
});
// todo here : inject services
$application = new Application($di);
$application->handle();
} catch (Exception $e) {
echo "<pre>";
echo $e;
} finally {
}