【问题标题】:Symfony 2 database_driver issueSymfony 2 database_driver 问题
【发布时间】:2015-02-22 19:41:40
【问题描述】:

我正在尝试开始使用 Symfony 2,因此我开始阅读并遵循 jobeet 教程。当我尝试使用此命令“php app/console dictionary:database:create”创建数据库时遇到问题,我收到此错误:

Symfony\Component\Config\Exception\FileLoaderLoadException]
here is no extension able to load the configuration for "database_driver"     (in C:\wamp\www\jobeet\app/config\parameters.yml). Looked for namespace "databas
_driver", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "oc_platform", "ens_jobeet", "
ebug", "acme_demo", "web_profiler", "sensio_distribution" in C:\wamp\www\jobeet\app/config\parameters.yml (which is being imported from "C:\wamp\www\jobee
\app/config\config.yml").

Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
here is no extension able to load the configuration for "database_driver" (in C:\wamp\www\jobeet\app/config\parameters.yml). Looked for namespace "databas
_driver", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra", "oc_platform", "ens_jobeet", "
ebug", "acme_demo", "web_profiler", "sensio_distribution"

这是我的parameters.yml文件内容:

database_driver: pdo_mysql

database_host: 127.0.0.1
database_port: null
database_name: jobeet
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt

如果有人可以帮助我,我将不胜感激。

【问题讨论】:

  • 你能发布你的parameters.yml文件吗?
  • 我将parameters.yml 文件内容添加到我的问题中
  • 您是否安装了 MySQL php 扩展? (在 ubuntu 上,试试sudo apt-get install php-mysql
  • 您的参数看起来不错,错误消息databas_driver 中有错字(缺少“e”)可能是因为这个。重新检查您的参数并清除缓存。

标签: symfony jobeet


【解决方案1】:

你的参数不对。您应该添加参数: key 作为“顶级”键,如下所示

parameters:
  database_driver: pdo_mysql
  database_host: 127.0.0.1
  database_port: null
  database_name: jobeet
  database_user: root
  database_password: null
  mailer_transport: smtp
  mailer_host: 127.0.0.1
  mailer_user: null
  mailer_password: null
  locale: en
  secret: ThisTokenIsNotSoSecretChangeIt

此外,我注意到您将 root 用户用作 db 用户并且不需要密码:这通常是一种不好的做法。

终于换了秘密令牌

【讨论】:

  • 他们很好,我只是忘了从我的参数文件中复制关键字参数。
  • @MOHAMEDABDELLAH:从你的错误来看,似乎没有
  • 是的,当然,我只是想说关键字参数已经在我的文件中。
猜你喜欢
  • 1970-01-01
  • 2013-03-17
  • 1970-01-01
  • 2017-12-01
  • 2014-10-06
  • 2014-07-31
  • 1970-01-01
  • 2013-03-26
  • 2015-08-15
相关资源
最近更新 更多