$di = new \Phalcon\DI\FactoryDefault();
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->set('url', function() use ($config) {
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri($config->application->baseUri);
return $url;
});
$di->set('voltService', function() {
$volt = new Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->setOptions(array(
"compiledPath" => "../app/compiled/",
"compiledExtension" => ".php"
));
return $volt;
});
/**
* Setting up the view component
*/
$di->set('view', function() use ($config) {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(".phtml" => 'voltService'));
return $view;
});
我使用这篇文章:http ://docs.phalconphp.com/en/0.6.0/reference/volt.html ,但提示错误消息
注意:未定义变量:查看 /var/www/html/phalconblog/public/index.php 第 40 行
注意:未定义的变量:第 40 行 /var/www/html/phalconblog/public/index.php 中的 di
致命错误:在第 42 行的 /var/www/html/phalconblog/public/index.php 中调用未定义的方法 Phalcon\Mvc\View\Engine\Volt::setOptions()