我选择了一个XML文件进行配置,但是当我运行./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
这是我的推动.xml文件
<?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>
.. 和我的架构.xml文件
<?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 配置文件的详细信息,然后它简单地说要运行命令。但是,我收到此错误?有什么建议吗?
然后我只是尝试使用PHP文件进行数据库配置(propel.php),这次命令运行没有错误。但是,我的数据库没有创建。我也尝试运行 vendor/bin/propel model:build 以查看它是否生成了我的类,这也运行没有错误,但我看不到它在哪里生成了我的类。
这两个配置文件都位于我的应用程序的根目录下,这也是我运行每个命令的位置。
似乎将配置文件放在 XML 中会产生有趣的问题——
我尝试使用在线转换器将XML转换为YML-这给了我一个可以追查的不同错误。
使用 propel.xml 文件时出错:
[Symfony'Component'Config'Definition'Exception'InvalidTypeException]
Invalid type for path "propel.database.connections.unrestricted.attributes". Expected array, but got string
使用 propel.yml 文件时出错:
[Symfony'Component'Yaml'Exception'ParseException]
Unable to parse at line 8 (near " settings: ").
我将重读此页面:
http://propelorm.org/documentation/reference/configuration-file.html
并进行我认为会有所帮助的任何编辑。我会在它工作时更新。
嗯,效果很好。
我使用了他们的模板,只是使用 .yml 格式替换了我的数据库信息。为了安全起见,我还在我的数据库中将我的多字节 4utf8 字符集更改为标准 UTF-8。
您应该
在config.xml
中注释属性标记。
此外,您在dsn-config.xml
中的dbname
应与schema.xml
中的数据库标签名称相同。
修复此问题并重试,这将很好用。