我刚接触Symfony和Doctrine的世界。
所以我按照文档来安装Symfony。一切都很顺利。
下一步:创建DB。我再次遵循文档(Databases and the Doctrine ORM)并运行命令php bin/console doctrine:database:create
这个命令没有给我任何输出,并且运行了超过30分钟,这对于创建一个数据库来说似乎是很多的。
我有一个本地mysql服务器在127.0.0.1:3000上运行
这是我的.env文件
###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=mysql://root:root@127.0.0.1:3000/my_project?serverVersion=8.0.19
###< doctrine/doctrine-bundle ###有人知道为什么这个命令没有给我任何输出吗?
发布于 2020-04-20 18:06:53
即使我不明白为什么,问题也解决了。
我编辑的doctrine.yaml就像这样
doctrine: dbal: url: '%env(resolve:DATABASE_URL)%'
至
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: my_project
user: root
password: root
host: localhost
driver: pdo_mysql
server_version: '8.0.19' # your database server version here
#url: '%env(resolve:DATABASE_URL)%'https://stackoverflow.com/questions/61318322
复制相似问题