[DDC-2486] Getting started does not work with current release Created: 04/Jun/13  Updated: 12/Mar/14  Resolved: 11/Sep/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.4, 2.4.1
Fix Version/s: 2.4
Security Level: All

Type: Documentation Priority: Minor
Reporter: Julian Picht Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: Cli
Environment:

Ubuntu 12.04



 Description   

The tutorial states: "This tutorial assumes you work with Doctrine 2.3 and above. Some of the code will not work with lower versions."

I'm using 2.3.4

When running "php vendor/bin/doctrine orm:schema-tool:create"

this happens:

PHP Fatal error: Call to undefined method Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet() in /var/www/project/cli-config.php on line 5
PHP Stack trace:
PHP 1.

{main}() /var/www/project/vendor/doctrine/orm/bin/doctrine:0
PHP 2. include() /var/www/project/vendor/doctrine/orm/bin/doctrine:4
PHP 3. require() /var/www/project/vendor/doctrine/orm/bin/doctrine.php:31

Fatal error: Call to undefined method Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet() in /var/www/project/cli-config.php on line 5

Call Stack:
0.0001 619840 1. {main}

() /var/www/project/vendor/doctrine/orm/bin/doctrine:0
0.0003 632072 2. include('/var/www/project/vendor/doctrine/orm/bin/doctrine.php') /var/www/project/vendor/doctrine/orm/bin/doctrine:4
0.0012 730208 3. require('/var/www/project/cli-config.php') /var/www/project/vendor/doctrine/orm/bin/doctrine.php:31

This is because some commits are not yet in the release. The current GIT version probably works but is not an option for me.



 Comments   
Comment by Benton Jackson [ 11/Jun/13 ]

I'm seeing this problem too. Kinda hard to learn Doctrine when the tutorial is brain dead.

Comment by Benton Jackson [ 11/Jun/13 ]

"CreateHelperSet" appears to be a method in 2.4. I adapted the "2.3 configuring the command line" code to make my "cli-config.php" file read like this, and it appears to work:

<?php
// cli-config.php
require_once "bootstrap.php";

$em = $entityManager;

$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));

Comment by Stephen Westman [ 23/Jun/13 ]

Thanks to Benton, I now have a working Doctrine app. I agree that it would be nice to have had this taken care of before release. However, as an old time guerrilla-type programmer, I can do "whatever works"!

Thanks again, Benton!

Comment by Mortensen Cristian [ 25/Aug/13 ]

Thanks Benton!

Comment by Benjamin Eberlei [ 11/Sep/13 ]

2.4 is now released and the tutorial works, sorry for the long disconnect

Comment by Vishal Bandre [ 03/Mar/14 ]

My working cli-config.php with latest fresh doctrine source as on Mar 03 2014.

Windows XP - Access doctrine without using php command like > vendor\bin\doctrine.

<?php // cli-config.php
use Doctrine\ORM\Tools\Console\ConsoleRunner;

// replace with file to your own project bootstrap
require_once 'bootstrap.php';

// replace with mechanism to retrieve EntityManager in your app
// $entityManager = GetEntityManager();

$em = $entityManager;
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
return ConsoleRunner::createHelperSet($em);

Comment by Igor Timoshenkov [ 11/Mar/14 ]

Hello, everyone.

I am trying to follow the Tutorial, but I am stuck with the cli generation. Here is my cli-config.php file:

<?php
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Setup;

require_once "vendor/autoload.php";

$modelsPath = realpath(_DIR_.'/../model');
$config = Setup::createAnnotationMetadataConfiguration(array($modelsPath), true);

// database configuration parameters
$conn = array(
'driver' => 'pdo_sqlite',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => 'someDb',
);

return ConsoleRunner::createHelperSet(EntityManager::create($conn, $config));

Now, when I run

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

I get Access denied. What am I doing wrong?

P.S. I am not using Symfony, Doctrine version is 2.4.1.

Comment by Vishal Bandre [ 12/Mar/14 ]

Which db driver are you using?

If you are using sqlite the conn parameters to be used are user, password, path, memory as described on http://docs.doctrine-project.org/projects/doctrine-dbal/en/2.0.x/reference/configuration.html but your connection array is showing wrong settings (these are MYSQL specific). Please check required db driver and try again.

Comment by Marco Pivetta [ 12/Mar/14 ]

Igor Timoshenkov's question was solved at http://stackoverflow.com/q/22336256/347063

Basically, his vendor/bin/doctrine was broken, but running php vendor/doctrine/orm/bin/doctrine worked fine.

Comment by Igor Timoshenkov [ 12/Mar/14 ]

Hi, guys.

Igor Timoshenkov's question was solved at http://stackoverflow.com/q/22336256/347063

My question is not solved.

If you are using sqlite the conn parameters to be used are user, password, path, memory as described on http://docs.doctrine-project.org/projects/doctrine-dbal/en/2.0.x/reference/configuration.html but your connection array is showing wrong settings (these are MYSQL specific). Please check required db driver and try again.

I have corrected the configuration parameters - I needed pdo_mysql, not pdo_sqlite. But the php vendor/bin/doctrine orm:schema-tool:create is still not working. Any ideas what else could that be?

BTW, the link to the configuration should be added to the Tutorial.

Comment by Vishal Bandre [ 12/Mar/14 ]

Will you please share/paste full error message here?

Check for missing db password, etc.

Generated at Sun Aug 31 04:25:43 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.