最近我用它自己的用户创建了一个额外的数据库。因此,我在parameters.yml
中创建了一个额外的数据库驱动程序。据我所知,这是针对这种情况的标准方法。到目前为止,它的确有效。在我创建的其中一个服务中,我可以使用此数据库驱动程序。在网站上运行代码时,根本没有问题。
但当然有问题,否则我不会要求你的帮助。
我尝试通过运行以下命令来安装插件:
$ ./composer.phar require pugx/autocompleter-bundle
这会出现以下错误:
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database_driver_geo". Did you mean this: "database_driver"?
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
Installation failed, reverting ./composer.json to its original content.
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
其他一些帖子说有关缓存的错误与文件/目录权限有关。但这似乎不是问题所在,因为当删除地理驱动程序的配置时,不会出现这类错误。
我正在运行Symfony 2.5
[编辑:已添加parameters.yml文件]
我的parameters.yml
看起来像这样:
# This file is auto-generated during the composer install
parameters:
# Default database
database_driver: pdo_mysql
database_host: ***
database_port: ***
database_name: ***
database_user: ***
database_password: ***
# Geo database
database_driver_geo: pdo_mysql
database_host_geo: ***
database_port_geo: ***
database_name_geo: ***
database_user_geo: ***
database_password_geo: ***
mailer_transport: ***
mailer_host: ***
mailer_user: ***
mailer_password: ***
locale: ***
secret: ***
[编辑:添加了config.yml文件]
config.yml
文件中的学说部分:
# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
mapping_types:
enum: string
bit: integer
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
geo:
driver: %database_driver_geo%
host: %database_host_geo%
port: %database_port_geo%
dbname: %database_name_geo%
user: %database_user_geo%
password: %database_password_geo%
charset: UTF8
mapping_types:
enum: string
bit: integer
# if using pdo_sqlite as your database driver, add the path in parameters.yml
# e.g. database_path: %kernel.root_dir%/data/data.db3
# path: %database_path%
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
***CoreBundle: ~
geo:
connection: geo
mappings:
***GeoBundle: ~
auto_generate_proxy_classes: %kernel.debug%
我希望有人可以帮助我解决这个问题。
亲切的问候,
马尔科姆
答案 0 :(得分:2)
如评论中所述,parameters.yml
文件在作曲家update
或install
命令后自动重建。您可以在composer.json
部分的scripts
文件中看到该内容:
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
// other commands...
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
// other commands...
]
},
如果您不喜欢它,您当然可以关闭此功能。但如果使用得当可能会有用。
因此,当您通过编辑器安装某个软件包时,您将丢失直接放入parameters.yml
的参数。
您应该做的是使用用于构建parameters.yml.dist
的{{1}}文件。它应该提供应用程序参数值(如果它们对于每个app实例都相同)或默认值,如果参数对于每个环境(prod / dev)都不同。
在您的情况下,它是第二个用例(默认值),因为每个服务器的DB凭据都会更改。它实际上与默认数据库连接的配置完全相同。 parameters.yml
包含这些参数的一些默认值。