原来的在自动创建的多模块项目中 app->config->services.php 最下面的代码
/**
* Configure the Volt service for rendering .volt templates
*/
$di->setShared('voltShared', function ($view) {
$config = $this->getConfig();
$volt = new VoltEngine($view, $this);
$volt->setOptions([
'compiledPath' => function($templatePath) use ($config) {
// Makes the view path into a portable fragment
$templateFrag = str_replace($config->application->appDir, '', $templatePath);
// Replace '/' with a safe '%%'
$templateFrag = str_replace('/', '_', $templateFrag);
return $config->application->cacheDir . 'volt/' . $templateFrag . '.php';
}
]);
return $volt;
});
里面的return $ templateFrag 带有路径 必须使用basename函数去掉 basename介绍
修改之后结果,多模块项目运行正常
/**
* Configure the Volt service for rendering .volt templates
*/
$di->setShared('voltShared', function ($view) {
$config = $this->getConfig();
$volt = new VoltEngine($view, $this);
$volt->setOptions([
'compiledPath' => function($templatePath) use ($config) {
// Makes the view path into a portable fragment
$templateFrag = str_replace($config->application->appDir, '', $templatePath);
// Replace '/' with a safe '%%'
$templateFrag = basename(str_replace('/', '_', $templateFrag));
return $config->application->cacheDir . 'volt/' . $templateFrag . '.php';
}
]);
return $volt;
});