C
C
Ch00ee2015-07-29 20:07:23
MySQL
Ch00ee, 2015-07-29 20:07:23

Why does symfony2 get into the database when clearing the cache?

Hello!
Such a problem: I wrap the project in docker, mysql is not there, in the post-install composer there is a line
- "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
when executed, it gives

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111)' in /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43
Stack trace:
#0 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(43): PDO->__construct('mysql:host=127....', 'root', NULL, Array)
#1 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php(45): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=127....', 'root', NULL, Array)
#2 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(360): Doctrine\DBAL\Driver\PDOMySql\Driver->connect(Array, 'root', NULL, Array)
#3 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): Doctrine\DBAL\Connection->connect()
#4 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#5 /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#6 / in /build/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php on line 115
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception



  [RuntimeException]
  An error occurred when executing the "'cache:clear --no-warmup'" command.

is it possible to somehow do without installing mysql and cutting out the doctrine?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis, 2015-07-30
@Ch00ee

doctrine/dbal >= 2.5 is not supported due to backward compatibility.
Downgrade Doctrine.
For example like this

"require": {
        "php": ">=5.3.9",
        "symfony/symfony": "2.7.*",
        "doctrine/orm": "~2.2,>=2.2.3,<2.5",
        "doctrine/dbal": "<2.5",
        "doctrine/doctrine-bundle": "~1.4",
   ........

A
Alexey Pavlov, 2015-07-29
@lexxpavlov

When you run the console command, the kernel (kernel) is launched, which parses the parameters from config.yml and initializes the bundles. The doctrine bundle is attached to the database. Whether something can be done about it, I don't know.
Maybe the solution would be to make your own environment level (environment), in which not to add the doctrine bundle, and run this environment when you call the console command.

K
khaliullov, 2018-06-18
@khaliullov

everything is easier as soon as you specify in the config

server_version: 9.5
.
For example:
# Doctrine Configuration
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset : UTF8
server_version: 9.5
it for PSQL, for MySQL it is necessary to specify something like 5.6.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question