服务 "sonata.admin.block.admin_list" 依赖于不存在的服务 "sonata.templating"

The service "sonata.admin.block.admin_list" has a dependency on a non-existent service "sonata.templating"

我使用的是 Sonata Admin Bundle 版本 3.31.1,在更新我的作曲家后它开始出现以下错误

The service "sonata.admin.block.admin_list" has a dependency on a non-existent service "sonata.templating".

我的 symfony 是 3.4,这里是 composer.json 文件

{
    "name": "msen/api",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "require": {
        "php": ">=7.1.6",
        "ext-intl" : "*",
        "symfony/symfony": "^3.4",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^3.1",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "liuggio/excelbundle": "^2.0",
        "twig/extensions": "^1.4",
        "symfony/var-dumper": "^3.2",
        "payum/core": "^1.4",
        "league/uri": "~4.2",
        "php-http/guzzle6-adapter": "^1.1.1",
        "payum/paypal-express-checkout-nvp": "^1.3",
        "payum/offline": "^1.3",
        "payum/payum-bundle": "^2.2",
        "sonata-project/admin-bundle": "^3.31.1",
        "sonata-project/doctrine-orm-admin-bundle": "^3.3",
        "phpmailer/phpmailer": "^5.2",
        "symfony/config": "^3.3",
        "symfony/translation": "^3.3",
        "symfony/yaml": "^3.3",
        "aws/aws-sdk-php-symfony": "^1.3"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0",
        "phpunit/phpunit": "6.5.0"

    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
            "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    }
}

这是我放置 Sonata 的 AppKernel

 new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
 new Sonata\AdminBundle\SonataAdminBundle(),

它之前运行没有任何问题。奏鸣曲有什么bug吗?我之前确实升级到 Symfony 3.4 成功了。不过索纳塔好像变了? 有什么解决办法吗?

在 AppKernel.php 中添加这两行解决了问题

new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),

也许您在 config.yml:

中遗漏了这个
framework:
    ...
    templating:
        engines: ['twig']

确保在 AppKernel

中注册这些 Bundle
  • KnpMenuBundle
  • 奏鸣曲核心包
  • 奏鸣曲块

        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Sonata\CoreBundle\SonataCoreBundle(),
        new Sonata\BlockBundle\SonataBlockBundle(),
        new Sonata\AdminBundle\SonataAdminBundle(),