路径“propel.database.connections.project.attributes”的类型无效。预期的数组,但得到了字符串

时间:2017-09-22 16:30:28

标签: php xml symfony composer-php propel2

我正在尝试使用带有命令的schema.xml文件的Propel ORM创建SQL模式

.\vendor\bin\propel sql:build

我收到的错误是:

[Symfony\Component\Config\Definition\Exception\InvalidTypeException]
Invalid type for path "propel.database.connections.project.attributes". Expected array, but got string

这是我的propel.xml文件:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
    <propel>
        <database>
            <connections>
                <connection id="project">
                    <adapter>mysql</adapter>
                    <classname>Propel\Runtime\Connection\ConnectionWrapper</classname>
                    <dsn>mysql:host=localhost;dbname=project</dsn>
                    <user>root</user>
                    <password></password>
                    <attributes></attributes>
                </connection>
            </connections>
        </database>
        <runtime>
            <defaultConnection>project</defaultConnection>
            <connection>project</connection>
        </runtime>
        <generator>
            <defaultConnection>project</defaultConnection>
            <connection>project</connection>
        </generator>
    </propel>
</config>

这是我的schema.xml文件:

<database name="project" defaultIdMethod="native">
    <table name="user" phpName="User">
        <column name="id" type="integer" size="255" required="true" primarykey="true" autoincrement="true"></column>
        <column name="username" type="varchar" size="255" required="true"></column>
        <column name="password" type="varchar" size="255" required="true"></column>
        <column name="email" type="varchar" size="255" required="true"></column>
    </table>
</database>

1 个答案:

答案 0 :(得分:0)

通过在propel.xml中注释掉<attributes></attributes>标记来修复它:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<config>
    <propel>
        <database>
            <connections>
                <connection id="project">
                    <adapter>mysql</adapter>
                    <classname>Propel\Runtime\Connection\ConnectionWrapper</classname>
                    <dsn>mysql:host=localhost;dbname=project</dsn>
                    <user>root</user>
                    <password></password>
                    <!--
                    <attributes></attributes>
                    -->
                </connection>
            </connections>
        </database>
        <runtime>
            <defaultConnection>project</defaultConnection>
            <connection>project</connection>
        </runtime>
        <generator>
            <defaultConnection>project</defaultConnection>
            <connection>project</connection>
        </generator>
    </propel>
</config>