After updating to DBAL 2.5, Doctrine introduced Doctrine\DBAL\Connection::detectDatabasePlatform() which is different than 2.4. Now in 2.5, any time a repository is instantiated (not even used) by the DI, we get a PDOException if the DB doesn't already exist.
Imagine trying to run app/console doctrine:database:create and getting a "Database doesn't exist!" error. Repositories as services are very common in most projects, so this is a huge issue.
To illustrate quickly, create a fresh Symfony project, letting composer install the AcmeDemoBundle. Then, while trying to generate an entity, you'll get the PDOException.
composer create-project symfony/framework-standard-edition symfony-standard
cd symfony-standard
app/console doctrine:generate:entity --entity=AcmeDemoBundle:Foo
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database 'testdb'
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [1049] Unknown database 'testdb'
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'testdb'
This seems because you're relying in the auto-detection of platform to be used.
Configure the platform to be used as part of DoctrineBundle and live happy. =)
I'm glad you've found a solution! But I'm struggling to put that into code. Could you help me change the above app/console doctrine:generate:entity --entity=AcmeDemoBundle:Foo command to work with your platform idea?
http://symfony.com/doc/current/reference/configuration/doctrine.html
Search for platform_service.
I am surprised that installing a new copy of Symfony and running app/console doctrine:generate:entity gives me an error out of the box. I am especially surprised because doctrine:generate:entity used to work right out of the box. And now it doesn't.
Please remember, I am using all of the Symfony Standard defaults. I have change nothing from the standard, so everything should just work.
Symfony documentation doesn't say you need to create a custom platform_service in order to run the doctrine:generate:entity command. I would expect this command to continue to work like it used to before DBAL 2.5. platform_service was never required until now. This is a breaking change, isn't it?
http://symfony.com/doc/current/bundles/SensioGeneratorBundle/commands/generate_doctrine_entity.html
@mattjanssen might be... I'm giving you a hand to address the issue right now.
Tomorrow I will discuss with others on how to fix this. =)
For know you can simply provide the version of the database server you are connecting to like this:
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: Symfony2
user: root
password: null
host: localhost
driver: pdo_mysql
server_version: 5.6 # your database server version here
As a workaround until we find a solution.
See http://www.doctrine-project.org/jira/browse/DBAL-1057 for the DBAL issue
Thank you @deeky666, @guilhermeblanco and @stof for confirming the issue! I was afraid this would be another "me" issue that no one else was experiencing. Those get very frustrating. Can I close this one then?
I will keep it opened for now, until we see whether Doctrine can improve this to avoid guessing too early. I will give more visibility to this issue (and hopefully avoid too many duplicates).
Same for me @mattjanssen.
I reverted back to DoctrineBundle 1.2 and DBAL 2.4.3 to avoid the issue.
@thundo you can keep using DoctrineBundle 1.3. DoctrineBundle itself is not related to this issue at all.
This is a problem for us because we use an installer UI to configure the database. Because of DBAL 2.5, the installer fails out of the box since the database isn't configured yet. In the installer, we give the option to select what driver to use and thus can't use the server_version workaround. Reverting to DBAL 2.4 was the only way fix I saw but that's not going to be an option in the long run.
@alanhartless we are still working on a solution. Until then if you cannot provide the server_version option please stick to 2.4 until we fixed the issue.
2.4 also shows this error... And not 2.3
I haven't tested yet with the server_version hack though.
@Taluu this is error is related to DBAL >= 2.5. If you get a similar error it must be something different.
Well, I can't create the database on 2.4, I have the error "the database doesn't exist". So it looks like the same error.... I can drop it if it exists, but that's all.
✘ talus@zoidberg > ~/dev/web/app > î‚ migrate-symfony > sf doctrine:database:create --force -vv
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database 'app_dev'
Exception trace:
() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103
Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:133
Doctrine\DBAL\DBALException::driverException() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at /home/talus/dev/web/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at /home/talus/dev/web/app/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:81
Doctrine\ORM\Mapping\ClassMetadataFactory->initialize() at /home/talus/dev/web/app/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:292
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/talus/dev/web/app/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:211
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/talus/dev/web/app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:265
Doctrine\ORM\EntityManager->getClassMetadata() at /home/talus/dev/web/app/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:67
Doctrine\ORM\Repository\DefaultRepositoryFactory->createRepository() at /home/talus/dev/web/app/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:50
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at /home/talus/dev/web/app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:665
Doctrine\ORM\EntityManager->getRepository() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:5947
appDevDebugProjectContainer->getWisembly_Meeting_Security_Meeting_AccessRepositoryService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:6390
appDevDebugProjectContainer->getSecurity_Access_DecisionManagerService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:2980
appDevDebugProjectContainer->getSecurity_AuthorizationCheckerService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:2993
appDevDebugProjectContainer->getSecurity_ContextService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:6141
appDevDebugProjectContainer->getWisembly_RatingService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:4933
appDevDebugProjectContainer->getWisembly_Api4_QuoteService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:4814
appDevDebugProjectContainer->getWisembly_Api4_EventService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:4920
appDevDebugProjectContainer->getWisembly_Api4_OrganizationService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/app/cache/dev/appDevDebugProjectContainer.php:5303
appDevDebugProjectContainer->getWisembly_Corebundle_Listener_OrganizationService() at /home/talus/dev/web/app/app/bootstrap.php.cache:2097
Symfony\Component\DependencyInjection\Container->get() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:188
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->lazyLoad() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php:128
Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->getListeners() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:215
Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->preProcess() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:107
Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:878
Symfony\Component\Console\Application->doRunCommand() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/talus/dev/web/app/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /home/talus/dev/web/app/app/console:22
And the server_version makes it work (even if I only put the major value, such as 5 for 5.5 or 5.6). And also for Doctrine 2.5, so this really looks like the same problem to me
@Taluu I can see from your stack trace that you are actually using DBAL 2.5. Therefore it's the same issue, yes.
Yes, just saw on the orm\'s composer that 2.5 is used with the orm on 2.4 (as I have only the orm specified in my composer). So it is indeed a 2.5 error then. My bad.
Is there any progress on this issue ?
I was really looking forward to DBAL 2.5 due to its support for INSERTs in QueryBuilder, but I can't upgrade unless this problem is fixed.
Hi @SoboLAN
You can add server_version to your config
doctrine:
dbal:
default_connection: default
connections:
default:
dbname: Symfony2
user: root
password: null
host: localhost
driver: pdo_mysql
server_version: 5.6
or if you use the simplified notation
doctrine:
dbal:
dbname: Symfony2
user: root
password: null
host: localhost
driver: pdo_mysql
server_version: 5.6
@KingCrunch Does that mean that it won't be fixed and we should always add server_version from now on ?
@SoboLAN I don't know. I'd guess if somebody comes up with a PR nobody would decline it :smile:
@SoboLAN please follow the DBAL issue I linked in https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-65772073 to see any progress done on the resolution. This is where the discussion should happen given that it is not an issue in the bundle itself.
And btw, note that in case you know the MySQL version used by your server (which should be the case most of the time), configuring it explicitly instead of relying on guessing the version will save you 1 DB call for each connection to your database, so it is a good idea to use the explicit configuration anyway.
Does the "old" version work with newer server versions?
Because if it does, then that should maybe the default if nothing is explicitly configured, along with a notice that setting explicitly it may improve performance for newer server versions or whatever.
@dzuelke in the case of MySQL, yes (the new version just provides a better way to rename indexes thanks to new MySQL features). In the case of SQLServer, no (there is some breaking changes between the different versions)
It's all and only about renaming tables ?! O_o :confused:
@KingCrunch for MySQL, the 5.7 platform is about renaming indexes and updating the list of reserved keywords. But for other platforms, it is about much bigger changes (native JSON field in PostgreSQL 9.2+ for instance)
Wouldn't a good first step then to be defaulting to the old version for MySQL, and catching the exception and throwing another one saying that server_version is required for MSSQL or Postgres?
That seems like a really low-hanging fruit that would eliminate the problem in 99.975% of cases (because the default config has a MySQL connection in it).
Once again, please discuss this in the DBAL issue (I posted the link above in this discussion), because it is something the DBAL team is responsible for solving, not the DoctrineBundle team (and there is already some discussion there)
@stof it is not true, that manually declaring the server version saves you 1 DB call. The auto detection feature was intended to avoid that by using the server info from the driver when connected. Drivers that do not provide server info directly and require an extra query, are not supported by the new auto detection feature.
oh, I thought some of them were requiring a server roundtrip
Does anyone know the status now? I don't see a fix, but I'm not able to repeat the behavior anymore with the original directions. I added doctrine/doctrine2#1294, which I hoped would fix the biggest use-case causing this error, but there hasn't been a new tag with that release yet, so that _shouldn't_ yet be fixing things.
Thanks!
Closing as the issue is resolved. I'm not getting that error anymore when using the latest versions.
Oh I cannot close. Someone else has to.
Closing as the issue is resolved
Reference or it didn't happen
@Ocramius I think it is https://github.com/doctrine/doctrine2/pull/1294 (and https://github.com/doctrine/doctrine2/commit/e05930e71482df06982c332b8820a1ae51bd7f28 for the backport, for which it would be great to tag doctrine/orm 2.4.8)
Yup, but I can prepare a release sometime next week only, if time allows it
On Apr 17, 2015 15:08, "Christophe Coevoet" [email protected]
wrote:
@Ocramius https://github.com/Ocramius I think it is
doctrine/doctrine2#1294 https://github.com/doctrine/doctrine2/pull/1294
(and doctrine/doctrine2@e05930e
https://github.com/doctrine/doctrine2/commit/e05930e71482df06982c332b8820a1ae51bd7f28
for the backport, for which it would be great to tag doctrine/orm 2.4.8)—
Reply to this email directly or view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-93982250
.
@Ocramius reminder to tag please
Won't get to it atm.
Marco Pivetta
On 23 April 2015 at 16:27, Tobias Schultze [email protected] wrote:
@Ocramius https://github.com/Ocramius reminder to tag please
—
Reply to this email directly or view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-95624919
.
Still not possible?
I'll see what I can do tomorrow, but I can't guarantee it.
Marco Pivetta
On 2 May 2015 at 01:51, Tobias Schultze [email protected] wrote:
Still not possible?
—
Reply to this email directly or view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-98271857
.
Thanks @Ocramius :)
ping
ping
Not yet happening.
Marco Pivetta
On 27 May 2015 at 12:41, Tobias Schultze [email protected] wrote:
ping
—
Reply to this email directly or view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-105880150
.
@Ocramius Anything we can do to help? Or is there a longer-term solution where we can help offload some of this work to someone else?
No, I simply need to free myself from paid work :-)
Marco Pivetta
On 27 May 2015 at 14:37, Ryan Weaver [email protected] wrote:
@Ocramius https://github.com/Ocramius Anything we can do to help? Or is
there a longer-term solution where we can help offload some of this work to
someone else?—
Reply to this email directly or view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-105911936
.
ping
Ping. This is getting ridiculously embarassing and frustrates alot of people. See symfony/symfony-standard#825
I will tag when I actually get to it, sorry, but I cannot promise anything given my current IRL situation.
If this is getting "ridiculausly embarassing" then I'm sorry, but you can keep your lower ORM version, since it works.
Nvm, this has already been taken care of:
https://github.com/doctrine/dbal/commit/0f36c99184e28c1ae9ca62853b15a29acc33823d
Hi all, is there a similar workaround when using PDO sessions ?
parameters:
pdo.db_options:
db_table: Session
db_id_col: session_id
db_data_col: session_value
db_time_col: session_time
db_lifetime_col: session_lifetime
services:
pdo:
class: PDO
arguments:
dsn: "mysql:dbname=%database_name%"
user: "%database_user%"
password: "%database_password%"
# server_version : 5.7 here __ by any chance ?
calls:
# \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION
- [setAttribute, [3, 2]]
In composer, using :
"doctrine/orm" : "2.4",
"doctrine/doctrine-bundle" : "1.3",
doesn't work (_or I'm doing something wrong_)
Thanks !
@tchapi You are using pdo directly. This has nothing to do with doctrine. The solution to your problem is to lazy connect. The pdosessionhandler supports that. Instead of passing the pdo instance to the constructor, you can pass the dns string as first argument. And user, password as connection options.
Thanks @Tobion ! I will try that
@Ocramius @Tobion, just updated doctrine/orm to dev-master in order to get the fix, I got the same problem. Seems to not be resolved for me.
$ composer info -i | grep doctrine
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.4.2 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.5.1 Common Library for Doctrine projects
doctrine/data-fixtures v1.1.1 Data Fixtures for all Doctrine Object Managers
doctrine/dbal v2.5.2 Database Abstraction Layer
doctrine/doctrine-bundle v1.5.2 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle v1.0.1 Symfony2 Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle v2.2.1 Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle v1.1.0 Symfony DoctrineMigrationsBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations v1.1.0 Database Schema migrations using Doctrine DBAL
doctrine/mongodb 1.2.0 Doctrine MongoDB Abstraction Layer
doctrine/mongodb-odm 1.0.2 Doctrine MongoDB Object Document Mapper
doctrine/mongodb-odm-bundle 3.0.1 Symfony2 Doctrine MongoDB Bundle
doctrine/orm dev-master e91bce5 Object-Relational-Mapper for PHP
@Soullivaneuh are you still able to get the "Unknown Database" error when running some app/console command? Can you post a fork of the SE or instructions on how to repeat? We weren't totally sure that we squashed all the situations where that may have been asking for a connection when one wasn't necessarily needed, but I stopped being able to reproduce.
Are you registering custom DBAL types ?
are you still able to get the "Unknown Database" error when running some app/console command?
Yes:
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[42000] [1049] Unknown database 'sdfsdfsd'
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000] [1049] Unknown database 'sdfsdfsd'
[PDOException]
SQLSTATE[42000] [1049] Unknown database 'sdfsdfsd'
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
Can you post a fork of the SE or instructions on how to repeat?
Will take a look for this, yes.
Are you registering custom DBAL types ?
@stof Yes. Here is my full config:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
driver_class: AppBundle\DBAL\Driver
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
powerdns:
driver: pdo_mysql
driver_class: AppBundle\DBAL\Driver
host: "%powerdns_host%"
port: "%powerdns_port%"
dbname: "%powerdns_name%"
user: "%powerdns_user%"
password: "%powerdns_password%"
charset: UTF8
types:
json: Sonata\Doctrine\Types\JsonType
Note: my custom dbal driver is just an override of the vendor one for the get truncate sql part.
Question: Does this version include the fix? https://github.com/doctrine/doctrine2/releases/tag/v2.5.1
@Soullivaneuh I thought you posted a stack trace, but I cannot find it anymore as it is not here
@Soullivaneuh I recently had this issue - does adding server_version help? (http://blog.insight.sensiolabs.com/2014/12/22/making-symfony-bootable-with-dbal-2-5.html)
@kbond Yes of course, in any versions, but it's a workaround, not a solution.
@weaverryan @stof I start a work to reproduce on SE but I got difficulties to reproduce the issue: https://github.com/symfony/symfony-standard/compare/2.7...Soullivaneuh:doctrine-bundle-issue-351
Maybe I missing something... any clue?
@Soullivaneuh can you give the stack trace again ? I cannot find the issue in which you posted it
I also had trouble reproducing the problem in a new project... An existing project would fail without server_version but a new project works just fine... Maybe a dep causes the issue? migrations-bundle maybe?
Also, according to this server_version gives a small performance boost - maybe it should be the solution...
@stof
$ ./app/console cache:clear -vvv
[2015-10-07 14:59:29] event.DEBUG: Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[2015-10-07 14:59:29] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
[2015-10-07 14:59:29] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
Clearing the cache for the dev environment with debug true
Clearing outdated warmup directory
Warming up cache
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[42000] [1049] Unknown database 'asdfghjk'
Exception trace:
() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103
Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:133
Doctrine\DBAL\DBALException::driverException() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php:106
Doctrine\Common\Persistence\ObjectManagerDecorator->getRepository() at /home/sullivan/tmp/project/src/AppBundle/Manager/DnsManager.php:67
AppBundle\Manager\DnsManager->__construct() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:7357
ap_DevDebugProjectContainer->getManager_DnsService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:2095
ap_DevDebugProjectContainer->getAdmin_PowerDnsDomainService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Admin/Pool.php:216
Sonata\AdminBundle\Admin\Pool->getInstance() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Route/RoutesCacheWarmUp.php:52
Sonata\AdminBundle\Route\RoutesCacheWarmUp->warmUp() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2641
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2411
Symfony\Component\HttpKernel\Kernel->boot() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:128
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:90
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:886
Symfony\Component\Console\Application->doRunCommand() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /home/sullivan/tmp/project/app/console:32
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000] [1049] Unknown database 'asdfghjk'
Exception trace:
() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47
Doctrine\DBAL\Driver\PDOConnection::__construct() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:45
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php:106
Doctrine\Common\Persistence\ObjectManagerDecorator->getRepository() at /home/sullivan/tmp/project/src/AppBundle/Manager/DnsManager.php:67
AppBundle\Manager\DnsManager->__construct() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:7357
ap_DevDebugProjectContainer->getManager_DnsService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:2095
ap_DevDebugProjectContainer->getAdmin_PowerDnsDomainService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Admin/Pool.php:216
Sonata\AdminBundle\Admin\Pool->getInstance() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Route/RoutesCacheWarmUp.php:52
Sonata\AdminBundle\Route\RoutesCacheWarmUp->warmUp() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2641
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2411
Symfony\Component\HttpKernel\Kernel->boot() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:128
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:90
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:886
Symfony\Component\Console\Application->doRunCommand() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /home/sullivan/tmp/project/app/console:32
[PDOException]
SQLSTATE[42000] [1049] Unknown database 'asdfghjk'
Exception trace:
() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
PDO->__construct() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Doctrine\DBAL\Driver\PDOConnection->__construct() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:45
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at /home/sullivan/tmp/project/vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManagerDecorator.php:106
Doctrine\Common\Persistence\ObjectManagerDecorator->getRepository() at /home/sullivan/tmp/project/src/AppBundle/Manager/DnsManager.php:67
AppBundle\Manager\DnsManager->__construct() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:7357
ap_DevDebugProjectContainer->getManager_DnsService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/app/cache/de_/ap_DevDebugProjectContainer.php:2095
ap_DevDebugProjectContainer->getAdmin_PowerDnsDomainService() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2155
Symfony\Component\DependencyInjection\Container->get() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Admin/Pool.php:216
Sonata\AdminBundle\Admin\Pool->getInstance() at /home/sullivan/tmp/project/vendor/sonata-project/admin-bundle/Route/RoutesCacheWarmUp.php:52
Sonata\AdminBundle\Route\RoutesCacheWarmUp->warmUp() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2641
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /home/sullivan/tmp/project/app/bootstrap.php.cache:2411
Symfony\Component\HttpKernel\Kernel->boot() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:128
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:90
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:886
Symfony\Component\Console\Application->doRunCommand() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:195
Symfony\Component\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:96
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/sullivan/tmp/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
Symfony\Component\Console\Application->run() at /home/sullivan/tmp/project/app/console:32
cache:clear [--no-warmup] [--no-optional-warmers]
Also, according to this server_version gives a small performance boost - maybe it should be the solution...
@kbond Thanks for the interesting link. But it's still a workaround for this issue. :-)
Also, according to this server_version gives a small performance boost - maybe it should be the solution...
Actually, I was wrong there when saying that MySQL is impacted. PDO and MySQLi do not require to run a query to get the version, only to connect (SQLAnywhere requires to run a query though).
@Soullivaneuh the fix in the ORM was to avoid retrieving the database platform eagerly, to avoid triggering the detection of the database platform earlier than necessary (as it may not even be necessary).
But in your case, the SonataAdminBundle routing cache warmer loads the ORM mapping for classes. And depending on the way you generate ids for your entity, the platform may be necessary to determine the mapping. Here is the list of different cases for the id generator strategy (set via the @ORM\GeneratedValue annotation, defaulting to none if there is no annotation):
auto: platform needed to decide whether the strategy used is sequence or identityidentity: platform needed (to know whether the platform supports it natively, or emulates it with sequences, as it changes the retrieval of the inserted id)sequence: platform needed (to build the sequence name based on the platform specificities)none: platform not needed (ids are assigned by the application)uuid: platform not needed to build the mappingcustom: platform not needed to build the mapping@stof, thanks for the tip, it's a progress.
But it's still a problem IMO. This works for a fresh install of Symfony, but not if a developer want to clone an existing project with configured entities with @ORM\GeneratedValue(strategy="AUTO").
BTW, this strategy is the default chosen when we generate one from the doctrine command.
SonataAdminBundle routing cache warmer loads the ORM mapping for classes
Where did you find that?
Oh, on the trace indeed.
BTW, this strategy is the default chosen when we generate one from the doctrine command.
Where did you find that?
in the stack trace: Sonata\AdminBundle\Route\RoutesCacheWarmUp->warmUp()
but actually, the issue is not there, but in your own project (except that your admin class depends on this service): AppBundle\Manager\DnsManager->__construct(). Instantiating your class triggers the loading of some ORM metadata (to get the repository for the class). You should delay it until it is needed.
I agree, thanks for the useful information. :+1:
:+1:
Does anyone know the latest workaround for this problem?
I tried downgrading doctrine/dbal but got
$ composer require doctrine/dbal:2.4.\*
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/orm v2.5.4 requires doctrine/dbal >=2.5-dev,<2.6-dev -> satisfiable by doctrine/dbal[2.5.x-dev, v2.5.0, v2.5.0-BETA2, v2.5.0-BETA3, v2.5.0-RC1, v2.5.0-RC2, v2.5.1, v2.5.2, v2.5.3, v2.5.4] but these conflict with your requirements or minimum-stability.
- doctrine/orm v2.5.4 requires doctrine/dbal >=2.5-dev,<2.6-dev -> satisfiable by doctrine/dbal[2.5.x-dev, v2.5.0, v2.5.0-BETA2, v2.5.0-BETA3, v2.5.0-RC1, v2.5.0-RC2, v2.5.1, v2.5.2, v2.5.3, v2.5.4] but these conflict with your requirements or minimum-stability.
- doctrine/orm v2.5.4 requires doctrine/dbal >=2.5-dev,<2.6-dev -> satisfiable by doctrine/dbal[2.5.x-dev, v2.5.0, v2.5.0-BETA2, v2.5.0-BETA3, v2.5.0-RC1, v2.5.0-RC2, v2.5.1, v2.5.2, v2.5.3, v2.5.4] but these conflict with your requirements or minimum-stability.
- Installation request for doctrine/orm (locked at v2.5.4, required as ^2.4.8) -> satisfiable by doctrine/orm[v2.5.4].
Installation failed, reverting ./composer.json to its original content.
Without solving this problem doctrine:database:create is just a useless command!
@kissge as said several times previously, the best workaround is to specify the server version explicitly instead of relying on auto-guessing.
@stof Thanks, it worked for me.
@stof sorry to add more comments about this, but I'd like to say that:
server_version and our apps worked perfectly.cache:clear and getting database connection errors makes Symfony look stupid and buggy (and it's not even Symfony's fault!)I'm seeing lots of problems related to this on Travis, while deploying apps, etc. That's why I think this is a Doctrine bug that must be fixed.
@javiereguiluz can you paste a stack trace of the case where it occurs for you (by running the command in verbose mode) to see which code paths triggers a retrieval of the database platform too early ?
@stof sure! First, the relevant package versions used by this app:
$ composer show
doctrine/annotations v1.2.7 Docblock Annotations Parser
doctrine/cache v1.6.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.6.1 Common Library for Doctrine projects
doctrine/data-fixtures v1.1.1 Data Fixtures for all Doctrine Object Managers
doctrine/dbal v2.5.4 Database Abstraction Layer
doctrine/doctrine-bundle 1.6.2 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle 1.3.0 Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle 2.3.0 Symfony DoctrineFixturesBundle
doctrine/inflector v1.1.0 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.5.4 Object-Relational-Mapper for PHP
...
symfony/symfony v2.8.2 The Symfony PHP framework
...
When using this config:
doctrine:
dbal:
server_version: 5.5
Everything works perfect:
$ php app/console cache:clear
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
If I comment the server_version config:
doctrine:
dbal:
# server_version: 5.5
Nothing works anymore:
$ php app/console cache:clear -vvv
[2016-06-08 10:34:26] event.DEBUG: Notified event "console.command" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
[2016-06-08 10:34:26] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
[2016-06-08 10:34:26] event.DEBUG: Notified event "console.command" to listener "Symfony\Bridge\Monolog\Handler\ConsoleHandler::onCommand".
// Clearing the cache for the dev environment with debug true
// Clearing outdated warmup directory...
// Warming up cache...
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory
Exception trace:
() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:103
Doctrine\DBAL\Driver\AbstractMySQLDriver->convertException() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:133
Doctrine\DBAL\DBALException::driverException() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php:242
Doctrine\Common\Persistence\AbstractManagerRegistry->getRepository() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:568
ap_DevDebugProjectContainer->getApp_UserProviderService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:4210
ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:2658
ap_DevDebugProjectContainer->getSecurity_AuthorizationCheckerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:3760
ap_DevDebugProjectContainer->getTwigService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:794
ap_DevDebugProjectContainer->getCacheWarmerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/bootstrap.php.cache:2695
Symfony\Component\HttpKernel\Kernel->initializeContainer() at <my_project>/app/bootstrap.php.cache:2465
Symfony\Component\HttpKernel\Kernel->boot() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:134
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:860
Symfony\Component\Console\Application->doRunCommand() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
Symfony\Component\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:98
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:123
Symfony\Component\Console\Application->run() at <my_project>/app/console:27
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] No such file or directory
Exception trace:
() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47
Doctrine\DBAL\Driver\PDOConnection::__construct() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:45
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php:242
Doctrine\Common\Persistence\AbstractManagerRegistry->getRepository() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:568
ap_DevDebugProjectContainer->getApp_UserProviderService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:4210
ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:2658
ap_DevDebugProjectContainer->getSecurity_AuthorizationCheckerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:3760
ap_DevDebugProjectContainer->getTwigService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:794
ap_DevDebugProjectContainer->getCacheWarmerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/bootstrap.php.cache:2695
Symfony\Component\HttpKernel\Kernel->initializeContainer() at <my_project>/app/bootstrap.php.cache:2465
Symfony\Component\HttpKernel\Kernel->boot() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:134
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:860
Symfony\Component\Console\Application->doRunCommand() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
Symfony\Component\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:98
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:123
Symfony\Component\Console\Application->run() at <my_project>/app/console:27
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
Exception trace:
() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
PDO->__construct() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Doctrine\DBAL\Driver\PDOConnection->__construct() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:45
Doctrine\DBAL\Driver\PDOMySql\Driver->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:360
Doctrine\DBAL\Connection->connect() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:429
Doctrine\DBAL\Connection->getDatabasePlatformVersion() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:389
Doctrine\DBAL\Connection->detectDatabasePlatform() at <my_project>/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:328
Doctrine\DBAL\Connection->getDatabasePlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:763
Doctrine\ORM\Mapping\ClassMetadataFactory->getTargetPlatform() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:632
Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:174
Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:332
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:78
Doctrine\ORM\Mapping\ClassMetadataFactory->loadMetadata() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:216
Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:281
Doctrine\ORM\EntityManager->getClassMetadata() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php:44
Doctrine\ORM\Repository\DefaultRepositoryFactory->getRepository() at <my_project>/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:698
Doctrine\ORM\EntityManager->getRepository() at <my_project>/vendor/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php:242
Doctrine\Common\Persistence\AbstractManagerRegistry->getRepository() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:568
ap_DevDebugProjectContainer->getApp_UserProviderService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:4210
ap_DevDebugProjectContainer->getSecurity_Authentication_ManagerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:2658
ap_DevDebugProjectContainer->getSecurity_AuthorizationCheckerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:3760
ap_DevDebugProjectContainer->getTwigService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/cache/de_/ap_DevDebugProjectContainer.php:794
ap_DevDebugProjectContainer->getCacheWarmerService() at <my_project>/app/bootstrap.php.cache:2187
Symfony\Component\DependencyInjection\Container->get() at <my_project>/app/bootstrap.php.cache:2695
Symfony\Component\HttpKernel\Kernel->initializeContainer() at <my_project>/app/bootstrap.php.cache:2465
Symfony\Component\HttpKernel\Kernel->boot() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:134
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:259
Symfony\Component\Console\Command\Command->run() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:860
Symfony\Component\Console\Application->doRunCommand() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:192
Symfony\Component\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:98
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at <my_project>/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:123
Symfony\Component\Console\Application->run() at <my_project>/app/console:27
cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <command>
You are probably going to tell me that it's not Doctrine fault because: cache:clear -> cache warmup -> Twig -> Security -> user provider -> database connection.
However, please consider that:
Thanks!
@javiereguiluz As far as I can see, it's the warmup of the class metadata cache of the ORM that triggers it. This is imho independent from your user provider. Any application that has the ORM enabled via the DoctrineBundle will have this issue.
Copying the issue I reported in https://github.com/doctrine/dbal/issues/990#issuecomment-225172938 here.
Using Symfony3 with Doctrine 2.5 I have included the important parts of the stack trace where I am seeing the attached error on AWS using MariaDB as the database.
stacktrace.txt.
In this case the database exists and the application tried to do a query for a login request and it barfs.
The config.yml has the server_version specified as previously suggested elsewhere but still getting this error.
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
server_version: 5.6
I face the same issue, configuring the "server_version" key only allow to use the "getSchemaManager" function on the connection without the exception being thrown. I'm still not able to use the "createDatabase" function without troubles.
EDIT: seems that letting a "~" as the database name as it does not exist yet can help to do the trick.
this is crazy. Can someone finally close this issue, as a "won't fix" ?
It's pretty clear that it's not going to be handled by the dev team, yet the discussion (since Dec 2014, mind you) clearly shows that the expectation of the community is different.
Please close the issue and let's stop ranting about this and adjust to the new situation.
@andrzejwp some people would prefer to keep this issue open until it's solved. But I understand your frustration. Maybe you can _unsubscribe_ from this issue so you don't get further notifications? Thanks!
My frustration is not about the notifications, you know. That's something I know how to handle.
Replying to my previous comment https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-225175780 - the issue was a stale cache in our EB bundle amongst some other configuration issues which we have sorted. Sorry for thinking this was related to this.
For our use case, setting the server version is not enough. We run a multi-tenant platform that sets the connection according to (a) the request or (b) a console parameter. The problem is that there is no context available when the cache warmer is triggered. Once the cache warmer is only interested in creating the proxy classes, why not use ManagerRegistry::getManagerNames() along with doctrine.orm.*_configuration services to create them? It'd postpone the creation of the EntityManager and therefore avoids this issue.
@Ocramius @stof any thought? I'd be happy to provide a PR to fix it.
Basically, the idea is to provide only the required information (proxy_dir, auto_generate_proxy_classes, metadata_factory and proxy_factory) as static arguments for the DoctrineWarmer service at compile time, instead of injecting the ManagerRegistry
@marcospassos I faced this issue in the same kind of architecture : Sf app with multi-tenancy and with the need to connect/create database related to some request/console parameters.
Changing credentials depending on request and console parameters is not something we officially support.
And creating the proxies involves loading the mapping, which requires instantiating more than the configuration class (listeners can alter the mapping for instance)
@Renrhaf and and anyone interested in dynamic connections, I've wrote a proposal to introduce this possibility.
Going back to the issue, I wondering: Why doctrine has to specifically connect to the given database?
I mean, why it can't just connect to the server, without specified database and then, get the mysql version?
PDO case:
public function getServerVersion()
{
return PDO::getAttribute(PDO::ATTR_SERVER_VERSION);
}
I don't think the database is really useful here.
This may be a stupid question, but I prefer to be sure.
What do you think?
Also, connecting to the database while just getting a repository seems overkill IMO… getRepository should return a newly instanciated repository class, but any access to the database (or any other costly operation) should happen later, when using the repository.
@Soullivaneuh @greg0ire https://github.com/doctrine/DoctrineBundle/issues/561#issuecomment-238904950
Short story, if "getPlatform*" is called at any point and the driver does not know the version, it will try to detect the version.
In the beginning of dbal, there was only one platform per vendor. This have changed but the usage pattern of platforms have not.
I have the same problem with Symfony3 .
I generate Entity with php bin/console doctrine:generate:entity and with correct info,
but when I tried to generate crud faced with
it seems he didn't detect my Bundle and Entity. Tried this several times but still the same.
[RuntimeException]
Entity "Yms" does not exist in the "OfferaBundle" bundle. You may have mistyped the bundle name or maybe the entity doesn't exist yet (create it first with the "doctrine:generate:entity" command
).
@kimhemsoe if so, why doesn't getPlatform() assume the lowest common denominator?
In the meantime, Symfony standard edition could just ship with a MySQL version set as it does assume MySQL already.
What does "lowest common denominator" mean in this context? Newer platform
versions may break BC (like MySQL, which doesn't follow semver yet), which
has nothing to do with "common".
On 7 Mar 2017 3:14 a.m., "Dalibor Karlović" notifications@github.com
wrote:
@kimhemsoe https://github.com/kimhemsoe if so, why doesn't getPlatform()
assume the lowest common denominator?
In the meantime, Symfony standard edition could just ship with a MySQL
version set as it does assume MySQL already
https://github.com/symfony/symfony-standard/blob/master/app/config/config.yml#L45
.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-284651986,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakKtJawX377tBFpFytr1imuI4DXIUks5rjRH3gaJpZM4DEmKk
.
@Ocramius in that case, 5.7 is more strict, use that as "lowest common denominator"? I just feel being in a state where you cannot create a DB because you don't have a DB is wrong and hurtful to experience of new Symfony+Doctrine developers.
Just set your db version? It's not hard and it saves you a query per
request.
On 9 Mar 2017 3:38 a.m., "Dalibor Karlović" notifications@github.com
wrote:
@Ocramius https://github.com/Ocramius in that case, 5.7 is more strict,
use that as "lowest common denominator"? I just feel being in a state where
you cannot create a DB because you don't have a DB is wrong and hurtful to
experience of new Symfony+Doctrine developers.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/DoctrineBundle/issues/351#issuecomment-285288648,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakDWoFFDtvRpcPXlD_f_8D58e0a83ks5rj7qjgaJpZM4DEmKk
.
From what I understand, I problem come from the experience of using symfony (from scratch), so more usually from Symfony Standard Edition.
Given the advantage of specifying the version of the database, why not simply add a parameter in the app/config/parameters.yml file?
That which would give in the file app/config/config.yml:
doctrine:
dbal:
driver: "%database_driver%"
server_version: "%database_server_version%"
# ...
and in the file app/config/parameters.yml.dist:
parameters:
database_driver: pdo_mysql
database_server_version: 5.5
# ...
With the dependency incenteev/composer-parameter-handler (already required), the configuration can be changed at the Symfony Standard Edition installation.
Is not that a good compromise?
I think requiring first-time Symfony Standard installers to figure out that they must manually set the server_version in config.yml is asking too much of new users. I imagine people giving up on Symfony when they get nasty red errors while following the Getting Started examples.
So if parameters.yml.dist + ParameterHandler prompts them with a working default... :thumbsup: :thumbsup: :thumbsup:
Prompting: good
Pre-set version: not good
Someone make it happen ;-)
@Ocramius I did set the version, of course, but it took quite some time to figure out it's even needed, that's the reason I'm following this issue to begin with. :)
FYI I tried to fix this in DBAL via https://github.com/doctrine/dbal/pull/2671 now thanks to the comment by @Soullivaneuh which inspired me for this approach.
Handled in https://github.com/doctrine/dbal/pull/2671
Most helpful comment
For know you can simply provide the version of the database server you are connecting to like this:
As a workaround until we find a solution.