Symfony 3.4:服务 "nelmio_api_doc.formatter.html_formatter" 依赖于不存在的服务 "templating"

Symfony 3.4:The service "nelmio_api_doc.formatter.html_formatter" has a dependency on a non-existent service "templating"

这是 Symfony 3.4 项目composer.json 文件的要求部分

 "require": {
            "php": ">=5.5.9",
            "doctrine/doctrine-bundle": "^1.6",
            "doctrine/orm": "^2.5",
            "friendsofsymfony/rest-bundle": "^2.3",
            "incenteev/composer-parameter-handler": "^2.0",
            "jms/serializer-bundle": "^2.3",
            "nelmio/api-doc-bundle": "^2.12",
            "sensio/distribution-bundle": "^5.0.19",
            "sensio/framework-extra-bundle": "^5.0.0",
            "symfony/monolog-bundle": "^3.1.0",
            "symfony/polyfill-apcu": "^1.0",
            "symfony/swiftmailer-bundle": "^2.6.4",
            "symfony/symfony": "3.4.*",
            "symfony/templating": "^4.0",
            "twig/twig": "^1.0||^2.0"

解决这个问题,使用composer安装模板组件:

composer require symfony/templating

然后,在config.yml中的framework key下添加如下配置:

templating:
    engines: ['twig']