问题
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
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>
.. 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>
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?
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.
回答1:
It seems like having the configuration file in XML creates interesting issues--
I tried converting the XML to YML with an online converter-- which has given me a different error that I can chase down.
Error using the propel.xml file:
[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "propel.database.connections.unrestricted.attributes". Expected array, but got string
Error using the propel.yml file:
[Symfony\Component\Yaml\Exception\ParseException]
Unable to parse at line 8 (near " settings: ").
I am going to reread this page:
http://propelorm.org/documentation/reference/configuration-file.html
and make any edits I feel will help. I'll update when it works.
Well, it works great.
I used their template and just substituted my database information using the .yml format. I also change my multibyte4utf8 character sets to standard UTF-8 in my database just to be safe.
回答2:
You should comment attributes tag in your config.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.
来源:https://stackoverflow.com/questions/27250428/propel-xml-gives-me-an-error-invalid-type-for-path-propel-database-connection