我的印象是这是条令的配置问题。事实上,我的医生
`doctrine:
dbal:
dbname: mydatabase
host: localhost
port: 8889
user: root
password: root
driver: pdo_mysql
url: '%env(resolve:DATABASE_URL)%'
unix_socket: /Applications/MAMP/tmp/mysql/mysql.sock
charset: UTF8
override_url: true
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App`
当我用数据库进行测试时,它是有效的,但在Travis CI上,当我这样做时,构建
`language: php
php:
- '7.3'
services:
- mysql
script:
- composer install
- php bin/console doctrine:database:create --env=test
- php bin/console doctrine:schema:update --force --env=test
- php bin/console doctrine:fixtures:load -n --env=test
- php bin/phpunit`
travis在创建数据库时返回我:
`php bin/console doctrine:database:create --env=test 382[critical] Error thrown while running command "doctrine:database:create --env=test". Message: "An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory" 383 384 385In AbstractMySQLDriver.php line 112: 386 387 An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or dir`
当我删除conf原则中的override_url选项时,相同的构建在travis上有效,而不是像这样有错误的测试
`Not setting doctrine.dbal.override_url to true is deprecated. True is the only value that will be supported in doctrine-bundle 3.0` or
`DoctrineDBALDriverPDOException: SQLSTATE[HY000] [2002] Connection refused`
我还没有找到真正的解决方案,我觉得我的数据库配置很好。也许我需要将条令捆绑包升级到3.0?如果有人有线索,我就接。提前感谢
根据添加此折旧的PR,在override_url
设置为true
的情况下,特定于环境的配置可以覆盖数据库名称(以及其他参数(。
因此,检查config/packages/test/doctrine.yaml
是否覆盖了DATABASE_URL
的任何参数