Twig 在slim中使用时出现细枝错误

Twig 在slim中使用时出现细枝错误,twig,slim,Twig,Slim,嗨,我需要interate twig到Slim应用程序,我用composer安装twig,并即时输入我的脚本 <?php use Slim\Slim; use Slim\Views\Twig; use Noodlehaus\Config; use Codecourse\User\User; session_cache_limiter(false); session_start(); ini_set('display_errors','On'); define('INC_ROOT

嗨,我需要interate twig到Slim应用程序,我用composer安装twig,并即时输入我的脚本

<?php

use Slim\Slim;
use Slim\Views\Twig;

use Noodlehaus\Config;

use Codecourse\User\User;

session_cache_limiter(false);
session_start();

ini_set('display_errors','On');

define('INC_ROOT', dirname(__DIR__));

require INC_ROOT.'/vendor/autoload.php';

$app = new Slim([
    'mode' => file_get_contents(INC_ROOT.'/mode.php'),
    'view' => new Twig(),
    'template.path' => INC_ROOT . '/app/views'
]);
$app->view->setTemplatesDirectory("/views");

$app->configureMode($app->config('mode'), function() use ($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});



echo $app->config->get('db.driver');

require 'database.php';

$app->container->set('user', function() {
    return new User;
});

$app->get('/', function() use ($app) {
    $app->render('home.php');
});
这可能有点误导;您只需要设置
template.path
或调用
View::settemplatesddirectory
,但不能同时设置两者

如果您想使用后者,那么它将是:

$app->view->setTemplatesDirectory(INC_ROOT . '/app/views');
我愚蠢的错误

我必须使用

'templates.path' => INC_ROOT . '/app/views'
我有

'template.path' => INC_ROOT . '/app/views'

听起来好像你缺少一个“视图”目录。你创建目录了吗?这是正确的文件路径吗,应该改为
/app/views
吗?是的,我已经创建了目录/app/views。你的意思是使用
$app->view->settemplatesddirectory(“/app/views”)
这个产品在我注释行
$app->view->settemplatesddirectory(“/views”)时出现了相同的错误那么我有相同的error@mardon有趣的是,它没有被缓存在任何地方?我想它没有被缓存