0

I have a problem with doctrine-module console using zend framework 2 and postgresql

ricardo@notebook:/var/www/zendskeleton$ bin/doctrine-module orm:schema-tool:create
PHP Warning:  array_map(): An error occurred while invoking the map callback in /var/www/zendskeleton/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Module.php on line 138

Warning: array_map(): An error occurred while invoking the map callback in /var/www/zendskeleton/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Module.php on line 138
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL:  database "zend" does not exist' in /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('pgsql:host=loca...', 'postgres', 'morphy09', Array)
#1 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php(46): Doctrine\DBAL\Driver\PDOConnection->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#2 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOPgSql\Driver->connect(Array, 'postgres', 'postgres', Array)
#3 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /var/www/zendskeleton/vendor/doctrine/dbal/li in /var/www/zendskeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 930

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[08006] [7] FATAL:  database "zend" does not exist' in /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#1 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php(46): Doctrine\DBAL\Driver\PDOConnection->__construct('pgsql:host=loca...', 'postgres', 'postgres', Array)
#2 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOPgSql\Driver->connect(Array, 'postgres', 'postgres', Array)
#3 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /var/www/zendskeleton/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /var/www/utilcore/vendor/doctrine/dbal/li in /var/www/zendskeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 930

I have a doctrine.local.php config file:

<?php

return [
    'doctrine' => [
        'connection' => [
            'orm_default' => [
                'driverClass' =>'Doctrine\DBAL\Driver\PDOPgSql\Driver',
                'params' => [
                    'host'     => 'localhost',
                    'port'     => '5432',
                    'user'     => 'postgres',
                    'password' => 'postgres',
                    'dbname'   => 'zend',
                ]
            ]
        ]
    ]
];

Basically, I cant create my database using doctrine-module cli command.

Why i'm getting this error?

If I create the database using psql all the doctrine-module commands works very well, but the doctrine-module orm:schema-tool:create is there for this?

1 Answer 1

1

The error occurs because doctrine tries to create your tables in a a database called zend and this database doesn't exist. You should check your database setup and see if there is a database available with the name zend.

Sign up to request clarification or add additional context in comments.

3 Comments

But the command 'bin/doctrine-module orm:schema-tool:create' shouldn't create the database for me?
@RicardoSimas : The create-scheme command will create the database scheme in the given database. "It will drop or alter tables, indexes, sequences and such", so it won't create the database.
Thank you, now I understand what is happened here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.