I konfigurierte Volt Motor in Phalcon auf folgende Weise:Wie wird das Cache-Verzeichnis der obersten Ebene für kompilierte Volt-Vorlagen festgelegt?
// create dependency injector
$di = new Phalcon\DI\FactoryDefault();
// configure Volt compiler
$di->set('volt', function($view, $di) {
$volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->getCompiler()
->addFunction('strtotime', 'strtotime')
->addFunction('money_format', 'money_format')
->addFunction('slownie', 'Kwota::getInstance()->slownie');
$volt->setOptions(array(
'compiledPath' => '../cache/' // this directory EXISTS
));
return $volt;
});
// configure View for backend actions
$di->set('view', function() {
$view = new Phalcon\Mvc\View();
$view->setViewsDir('../app/51/views/');
$view->registerEngines(['.volt' => 'volt']);
return $view;
});
// configure View for custom content like E-mails, print-view, etc.
$di->set('simpleView', function() {
$view = new Phalcon\Mvc\View\Simple();
$view->setViewsDir('../app/volt/');
$view->registerEngines(['.volt' => 'volt']);
return $view;
});
Wie Sie sehen können, zusammengestellt .volt.php Vorlagen in ../cache Verzeichnis gespeichert werden sollen, aber sie sind im gleichen Ordner, in dem erzeugt. Voltvorlagen sind lokalisiert. Was ist falsch?
BTW ist es sicher zu verwenden gemeinsame (die gleiche) "Volt" -Komponente für mehrere View-Instanzen wie im obigen Beispiel? Beachten Sie, dass der Volt-Konstruktor das $ view-Argument akzeptiert.
Edit: Sie, weil sie stören verwenden können nicht mit anderen geteilt Volt Compiler sowohl für Ansicht und Simple.