1

我有依赖注入容器和树枝的问题,我使用Illuminate/Container

// Register templates.
$this->singleton('templates', function ($c) {
    $twig = new \Twig_Environment(
        new \Twig_Loader_Filesystem([$c['paths.templates']]),
        [
            'debug' => true,
            // 'cache' => $c['paths.cache']
        ]
    );

    $twig->addExtension(new \Twig_Extension_Debug());

    $twig->addGlobal('app', $c['app']);

    return $twig;
});

$c['app']是容器。

在我的模板文件中,我想访问我的绑定:

{{ app.config.siteName }}

但这对我不起作用,我认为这是一个问题,因为容器实现为 ArrayAcess

4

0 回答 0