我对编码这个网站很新,所以我很抱歉我会和/或不会犯错误。
我正在尝试为mongoDB生成setter和getter(使用symfony 3),但是当我输入控制台时
php C:\wamp64\www\test\app\console doctrine:mongodb:generate:documents MainBundle
我收到此错误:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "doctrine_mongodb.connections". Expected array, but got string
注意到关于yml和缩进的层次结构的主题并且无法找到正确的答案。正如我所说,我很新,并不知道这个系统如何工作,所以如果有人有任何想法可以在这里问题,请与我分享。 这是我的config.yml文件:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "@MainBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# handler_id set to null will use layout session handler from php.ini
handler_id: ~
fragments: ~
http_method_override: true
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
doctrine_mongodb:
connections: default
default:
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
答案 0 :(得分:2)
您缺少2个空格缩进:
doctrine_mongodb:
connections: default
default: # <-- here
server: mongodb://localhost:27017
options: {}
并且您不需要像default
那样为connections
指定connections: default
值:doctrine_mongodb:
connections:
default: # <-- indentation added here
server: mongodb://localhost:27017
options: {}
default_database: test_database
document_managers:
default:
auto_mapping: true
而是应该是一个数组。
所以有效的配置应该是:
tapply(df$B, df$A, mean)
另外,我发现你在配置文件的3/4中使用了4个空格缩进。我建议你在文件的每个地方使用相同的缩进,以便将来不会遇到任何麻烦,加上结构看起来会更加一致。
答案 1 :(得分:0)
错误很明显 - 只需将doctrine_mongodb.connections
值更改为array
即可。
# app/config/config.yml
doctrine_mongodb:
connections:
default:
server: mongodb://localhost:27017
options: {}