talz13
talz13

Reputation: 258

propel 2, mysql - No errors from reverse, no schema.xml created

I installed propel2 (~2.0@dev) with composer in my web project yesterday and spent the afternoon trying to get it to reverse engineer my existing mysql db.

First, I tried following the directions on:

http://propelorm.org/documentation/cookbook/working-with-existing-databases.html

But kept getting an "unable to connect" error:

./propel reverse "mysql:host={mysql domain};dbname={my db name};user={username};password={password}" --verbose
There was an error building XML from metadata: Unable to open connection
Schema reverse engineering failed.

So I went back to the documentation, and thought that maybe I need a propel.php config file. So I copied from the example, filling in the appropriate info for my db, and came up with this:

<?php

return [
    'propel' => [
        'database' => [
            'connections' => [
                'mpginfo' => [
                    'adapter'    => 'mysql',
                    'classname'  => 'Propel\Runtime\Connection\ConnectionWrapper',
                    'dsn'        => 'mysql:host={mysql domain};dbname={my db name}',
                    'user'       => '{username}',
                    'password'   => '{password}',
                    'attributes' => []
                ]
            ]
        ],
        'runtime' => [
            'defaultConnection' => 'mpginfo',
            'connections' => ['mpginfo']
        ],
        'reverse' => [
            'connection' => 'mpginfo'
        ],
        'generator' => [
            'defaultConnection' => 'mpginfo',
            'connections' => ['mpginfo']
        ]
    ]          
];

Once I created this propel.php file and re-ran the reverse command, I no longer receive the "Unable to open connection" error, but I also see no output whatsoever! I do not see a schema.xml file being created, and I don't see anything indicating that the command even ran.

Just to double check, I read How to enable PDO_MYSQL for CLI? and verified that the mysql driver for PDO is installed and enabled on my server:

$ php --ri pdo

PDO

PDO support => enabled
PDO drivers => sqlite, mysql

Any ideas what could be wrong with my setup? Are there other config files that I need to create? How can I get some output for further debugging?

Upvotes: 2

Views: 1584

Answers (2)

deargle
deargle

Reputation: 517

I kept my config file, ran --verbose like Vince suggested, and noticed that my schema.xml had been dropped in generated-reversed-database/schema.xml

Upvotes: 1

secondman
secondman

Reputation: 3287

Get rid of the config file, then use single quotes.

$ propel reverse --verbose 'mysql:host=domain;dbname=mydbname;user=username;password=password'

I was having exactly the same issue and this resolved it.

Upvotes: 0

Related Questions