所以我目前正在使用 Propel ORM (v2.00-dev) 开发一个小项目,我想我会第一次尝试使用 Vagrant。
我已经设置了 vagrant 服务器以允许外部 MySQL 连接,并构建了以下配置文件,因此每次我想从命令行运行 propel 时都不必 ssh 进入服务器
{
"propel": {
"paths": {
"outputDir": "./propel/",
"phpDir": "./propel/model/",
"sqlDir": "./propel/sql",
"phpConfDir": "./propel/conf"
},
"database": {
"connections": {
"project-local": {
"adapter": "mysql",
"dsn": "mysql:host=localhost;dbname=scotchbox",
"user": "root",
"password": "root",
"attributes": []
},
"project-remote": {
"adapter": "mysql",
"dsn": "mysql:host=192.168.33.10;dbname=scotchbox",
"user": "root",
"password": "root",
"attributes": []
}
}
},
"runtime": {
"defaultConnection": "project-local",
"connections": ["projeect-local","project-remote"]
},
"generator": {
"defaultConnection": "project-remote",
"connections": ["project-remote","project-local"]
}
}
}
与类似的配对schema.xml
:
<database name="project-remote">
<!-- lots of tables in here -->
</database>
现在,到目前为止,这一直很好。该应用程序使用 运行project-local
,当我从命令行运行 propel 时,它会project-remote
按预期切换到。
但是,当我尝试运行propel diff
时,出现以下错误:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
这表明在运行差异时,Propel 正在尝试使用runtime
连接设置而不是generator
那些。有什么办法可以改变这个吗?我检查了配置文档,但看不到任何有关设置连接的信息。
我还注意到该diff
命令有一个--connection
参数,但我找不到任何关于它的信息,也无法弄清楚如何使用它。我试过了:
propel diff --connection=project-remote
和
propel diff --connection="project-remote"
两者都导致以下错误
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The path "propel.database.connections..adapter" cannot contain an empty value, but got "".
那么,是否有人对如何为推进差异指定连接(并可能迁移)有任何想法?