Answer the question
In order to leave comments, you need to log in
Why isn't volt working?
Exception: Service 'voltService' wasn't found in the dependency injection container - such a line comes out
like this, I connected it in index.php:
// $view->registerEngines(
// [
// ".volt" => "voltService",
// ]
// );
use Phalcon\Loader;
use Phalcon\Tag;
use Phalcon\Mvc\Url;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\DI\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Mvc\View\Engine\Volt;
....
// Register Volt as a service
$di->set(
"voltService",
function ($view, $di) {
$volt = new Volt($view, $di);
$volt->setOptions(
[
"compiledPath" => "../app/compiled-templates/",
"compiledExtension" => ".compiled",
]
);
return $volt;
}
);
// Setting up the view component
$di['view'] = function() {
$view = new View();
$view->setViewsDir('../app/views/');
$view->registerEngines(
[
".volt" => "voltService",
]
);
return $view;
};
Answer the question
In order to leave comments, you need to log in
$volt->setOptions(
[
"compiledPath" => "../app/cache/",
"compiledExtension" => ".compiled",
]
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question