Answer the question
In order to leave comments, you need to log in
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.
Answer the question
In order to leave comments, you need to log in
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",
........
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.
everything is easier as soon as you specify in the config
server_version: 9.5.
# 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 questionAsk a Question
731 491 924 answers to any question