在 Laravel 5 中用 Twig 替换 Blade

Replacing Blade with Twig in Laravel 5

我正在尝试将 Laravel 的原生 Blade 模板换成 Symfony 的 Twig Templating Engine. However during the composer require of twigbridge 我收到以下错误:

Using version ^0.9.5 for rcrowe/twigbridge
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: twig/twig[1.x-dev, v2.4.4].
    - Can only install one of: twig/twig[v2.4.4, 1.x-dev].
    - Can only install one of: twig/twig[1.x-dev, v2.4.4].
    - rcrowe/twigbridge v0.9.5 requires twig/twig ~1.30 -> satisfiable by twig/twig[1.x-dev].
    - Installation request for rcrowe/twigbridge ^0.9.5 -> satisfiable by rcrowe/twigbridge[v0.9.5].
    - Installation request for twig/twig (locked at v2.4.4, required as ^2.4) -> satisfiable by twig/twig[v2.4.4].


Installation failed, reverting ./composer.json to its original content.

我可能误解了错误,有什么建议吗?

您需要将 rcrowe/twigbridge 更新到与 twig 版本 2.4.4 兼容的较新版本,或者将 twig 降级以使其与 rcrowe/twigbridge v0.9.5 兼容。

rcrowe/twigbridge 已在其 composer.json 要求中列出:

"twig/twig": "~1.30",

编辑

我看起来 0.9.5 是 rcrowe/twigbridge 的最新版本,所以您唯一的选择是使用旧版本的 twig/twig