symfony4:没有扩展能够加载“ doctrine_mongodb”的配置

时间:2018-09-28 15:36:51

标签: symfony4 doctrine-odm doctrine-mongodb

我在使用Symfony4.1配置教义odm时遇到问题

我收到有关作曲家更新的错误消息,cache:clear子命令

  

没有扩展程序能够加载以下配置   “ doctrine_mongodb”(在   /home/thomas/Documents/dev/blade/vm_api/config/packages/doctrine.yaml)。   寻找名称空间“ doctrine_mongodb”,找到“框架”

我的composer.json看起来不错

    {
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "alcaeus/mongo-php-adapter": "^1.1.5",
        "doctrine/mongodb-odm": "^1.2.4",
        "doctrine/mongodb-odm-bundle": "^3.5",
        "mongodb/mongodb": "1.3.2",
        "symfony/console": "*",
        "symfony/flex": "^1.1",
        "symfony/framework-bundle": "*",
        "symfony/yaml": "*"
    },
    "require-dev": {
        "symfony/dotenv": "*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*",
        "symfony/symfony": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    }
}

配置文件带有“普通”参数

parameters:
    # Adds a fallback DATABASE_URL if the env var is not set.
    # This allows you to run cache:warmup even if your
    # environment variables are not available yet.
    # You should not need to change this value.
    env(DATABASE_URL): ''

doctrine_mongodb:
  #default_commit_options: ~
  default_database: "%env(DATABASE_NAME)%"
  connections:
    default:
      server: "%env(DATABASE_HOST)%"
      options:
        username: "%env(DATABASE_USER)%"
        password: "%env(DATABASE_PASSWORD)%"
        authSource: "%env(DATABASE_AUTH_SOURCE)%"
        ssl: "%env(DATABASE_SSL%"
        replicaSet: "%env(DATABASE_REPLICA_SET)%"
  document_managers:
    default:
      mappings:
        DocumentBundle:
          type: annotation
          dir: Document/

我是4.1的新手,也许我做错了事

预先感谢

1 个答案:

答案 0 :(得分:0)

如果使用Flex,应自动启用捆绑软件。否则,您需要通过在项目的config / bundles.php文件中添加以下行来手动启用捆绑软件

// config/bundles.php
<?php

return [
    // ...
    Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle::class => ['all' => true],
];