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

时间:2018-02-12 17:49:43

标签: symfony sonata-admin symfony-sonata sonata

我正在使用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。但似乎索纳塔改变了吗? 有什么解决方法吗?

3 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

也许您在config.yml中缺少它:

framework:
    ...
    templating:
        engines: ['twig']

答案 2 :(得分:1)

确保在 AppKernel

中注册这些捆绑软件
  • KnpMenuBundle
  • SonataCoreBundle
  • SonataBlockBundle

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