dflydev / dflydev-doctrine-orm-service-provider

Doctrine ORM Service Provider
MIT License
209 stars 59 forks source link

Uncaught exception 'InvalidArgumentException' with message 'Identifier "default" is not defined. #63

Closed marcossegovia closed 8 years ago

marcossegovia commented 8 years ago

Hi people, It's been a few days trying to setup correctly the package and still have problems. After setting all the configuration and console tools, I'm getting this error and I cannot find the way to fix it.

The error is : PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "default" is not defined.' in /Users/Marcos/Documents/vagrant-starter/public/Malendar/vendor/pimple/pimple/lib/Pimple.php:78

And the strack trace: #0 /Users/Marcos/Documents/vagrant-starter/public/Malendar/vendor/dflydev/doctrine-orm-service-provider/src/Dflydev/Pimple/Provider/DoctrineOrm/DoctrineOrmServiceProvider.php(107): Pimple->offsetGet('default')

In my app.php code I got the following:

$app->register(new DoctrineServiceProvider(), array(
    'dbs.options' => array(
        'db' => array(
            'driver'   => 'pdo_mysql',
            'dbname'   => 'world',
            'host'     => 'localhost',
            'user'     => 'root',
            'password' => '****',
            'charset'  => 'utf8',
        ),
    )
));

$app->register(new DoctrineOrmServiceProvider, array(
    "orm.proxies_dir" => __DIR__ . "/var/cache/doctrine/proxy",
    "orm.em.options" => array(
        "mappings" => array(
            array(
                "type" => "yml",
                "namespace" => 'Malendar\Domain\Entities',
                "path" => __DIR__ . "/../src/Application/Resources/config/yaml/",
            ),
        ),
    ),
));

Also as I'm running ' php app/bin/console orm:validate-schema' Therefore in the console.php got the following:

....
//DOCTRINE
$console->setHelperSet(new Symfony\Component\Console\Helper\HelperSet(array(
    'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app["db"]),
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($app["orm.em"])
)));
$console->addCommands(array(
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand,
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand,
    new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand,
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand,
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand,
    new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand,
    new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand,
    new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand,
    new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand,
    new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand,
    new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand,
    new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand,
    new \Doctrine\ORM\Tools\Console\Command\InfoCommand,
    new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand,
    new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand,
    new \Doctrine\DBAL\Tools\Console\Command\ImportCommand,
    new \Doctrine\DBAL\Tools\Console\Command\ReservedWordsCommand,
    new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand
));
.....

I got the repo in https://github.com/MarcosSegovia/malendar, if there is something left you want to know.

I appreciate your time =D

c960657 commented 8 years ago
$app->register(new DoctrineServiceProvider(), array(
    'dbs.options' => array(
        'db' => array(

Try default instead of db.

marcossegovia commented 8 years ago

Hi Christian, thank you for the response. I finally made it work I had to change the dbs for db as I was using just one and without naming it:

$app->register(new DoctrineServiceProvider(), array(
    'db.options' => array(
            'driver'   => 'pdo_mysql',
            'dbname'   => 'world',
            'host'     => 'localhost',
            'user'     => 'root',
            'password' => '****',
            'charset'  => 'utf8',
    )
));

$app->register(new DoctrineOrmServiceProvider, array(
    "orm.proxies_dir" => __DIR__ . "/var/cache/doctrine/proxy",
    "orm.em.options" => array(
        "mappings" => array(
            array(
                'type' => 'yml',
                'namespace' => '',
                'path' => __DIR__ . "/../src/Application/Resources/config/yaml/",
            ),
        ),
    ),
));

Actually I'm getting problems with the mapping but that is another story. I guess I can close this.