3

I am following this tutorial. http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html

I am using mysql instead of sqlite.

Following command should create the database.

php vendor/bin/doctrine orm:schema-tool:create

But it is not creating any. If i manually create the database, following command works fine

php vendor/bin/doctrine orm:schema-tool:update --force

Any idea why that command is not working?

Doctrine version 2.4.1

2
  • what is the error msg in the cli after this: php vendor/bin/doctrine orm:schema-tool:create ? Commented Jan 1, 2014 at 20:43
  • did you tell your config all about your mysql connection? database, user, password ... Commented Apr 19, 2014 at 15:00

2 Answers 2

1

Try this link:

vendor/bin/doctrine-module orm:schema-tool:create

User doctrine-module instead of doctrine.

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

1 Comment

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
0

I was faced with a similar issue and found that the command below

php vendor/bin/doctrine orm:schema-tool:create

Doesn't create the DB itself, it only creates the schema/tables.

I solved this by doing the following:

<?php
include 'bootstrap.php';
use Doctrine\ORM\Tools\Console\ConsoleRunner,
    Doctrine\ORM\EntityManager;

try {
    $entityManager->getConnection()->connect();
}
catch(Exception $ex) {
    $connection = EntityManager::create([
        'driver'   => 'pdo_mysql',
        'host'     => MYSQL_HOST,
        'user'     => MYSQL_USERNAME,
        'password' => MYSQL_PASSWORD,
        'charset' => 'UTF8'
    ], $config)->getConnection();
    $connection->executeUpdate('CREATE DATABASE '.MYSQL_DATABASE.' CHARACTER SET utf8 COLLATE utf8_general_ci');
}
return ConsoleRunner::createHelperSet($entityManager);
?>

Basically the script attempts to connect to the specified database, if that fails it attempts to create the database (assuming that the user is allowed to perform database creation that is - might be prudent to delete this file after deployment).

Source: http://www.cstruter.com/blog/395

Comments

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.