问题描述
我选择使用 XML 文件进行配置,但在运行 ./vendor/bin/propel sql:build
I'm opting for an XML file for configuration, but I get the following error when i run ./vendor/bin/propel sql:build
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "propel.database.connections.cfs.attributes". Expected array, but got string
这是我的 propel.xml 文件
Here is my propel.xml file
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
<propel>
<database>
<connections>
<connection id="cfs">
<adapter>mysql</adapter>
<classname>Propel\Runtime\Connection\ConnectionWrapper</classname>
<dsn>mysql:host=localhost;dbname=cfs_development</dsn>
<user>cfs_user</user>
<password>cfs_pass</password>
<attributes></attributes>
</connection>
</connections>
</database>
<runtime>
<defaultConnection>cfs</defaultConnection>
<connection>cfs</connection>
</runtime>
<generator>
<defaultConnection>cfs</defaultConnection>
<connection>cfs</connection>
</generator>
</propel>
</config>
.. 和我的 schema.xml 文件
.. and my schema.xml file
<?xml version="1.0" encoding="UTF-8"?>
<database name="cfs" defaultIdMethod="native">
<table name="projects" phpName="Project" namespace="Cfs\Model">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
<column name="title" type="varchar" size="255" required="true" />
<column name="user_id" type="integer" required="true"/>
<foreign-key foreignTable="users" phpName="User">
<reference local="user_id" foreign="id"/>
</foreign-key>
</table>
<table name="users" phpName="User" namespace="Cfs\Model">
<column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true"/>
<column name="username" type="varchar" size="255" required="true" />
<column name="password" type="varchar" size="255" required="true" />
<column name="salt" type="varchar" size="255" required="true" />
</table>
</database>
我从官方文档中获取了 propel.xml 配置文件的详细信息,然后它说只是运行命令.但是,我收到此错误?有什么建议吗?
I took the details for the propel.xml config file from the official documetation, then it says simply to run the command. But, I get this error? Any suggestions?
然后我只是尝试使用 PHP 文件进行数据库配置 (propel.php),这次命令运行没有错误.但是,我的数据库没有创建.我也尝试运行 vendor/bin/propel model:build 以查看它是否生成了我的类,这也运行没有错误,但我看不到它生成我的类的位置.
I then simply tried to use a PHP file for database config (propel.php) and this time the command run without errors. But, my databases weren't created. I tried to run vendor/bin/propel model:build too to see if it generated my classes, this also run without errors, but I couldn't see where it generated my classes.
这两个配置文件都在我的应用程序的根目录下,这也是我运行每个命令的地方.
Both config files are at the root of my application, which is also where I am running each command from.
推荐答案
您应该在 config.xml
中注释属性标签.
You should comment attributes tag in your config.xml
.
此外,dsn-config.xml
中的 dbname
应该与 schema.xml
中的数据库标签名称相同.
Also your dbname
in dsn-config.xml
should be same with name of database tag in your schema.xml
.
修复此问题并重试,效果会很好.
Fix this and try again and that will work great.
这篇关于Propel.xml 给我一个错误 - 路径“propel.database.connections.cfs.attributes"的无效类型.预期的数组,但得到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!