php - composer install fails when unable to see mysql database -


tl;dr: composer install fails when post-install scripts can't see mysql server

i'm building docker container symfony application, , during build this

run export symfony_env=prod && \   composer install --prefer-dist --optimize-autoloader 

towards end of install, fails this

generating optimized autoload files     [doctrine\dbal\exception\driverexception]                                                                     exception occured in driver: sqlstate[hy000] [2003] can't connect mysql server on '127.0.0.1' (111)      [doctrine\dbal\driver\pdoexception]                                           sqlstate[hy000] [2003] can't connect mysql server on '127.0.0.1' (111)      [pdoexception]                                                                sqlstate[hy000] [2003] can't connect mysql server on '127.0.0.1' (111)     script sensio\bundle\distributionbundle\composer\scripthandler::clearcache handling post-install-cmd event terminated exception    [runtimeexception]                                                            error occurred when executing "'cache:clear --no-warmup'" command.   

now, use --no-scripts presumably i'd need run composer install again after starting container, , i'd container ready possible.

as i've not found many references similar problems, there might in application @ fault, , suspect i'll answering own question. hope in describing it, figure out. alas, haven't. clues welcome :)

doctrine introduced code tried auto-detect things database quite eagerly.

a workaround tell doctrine target server version, e.g.

doctrine:     dbal:         default_connection: default         connections:             default:                 dbname:   symfony2                 user:         root                 password: null                 host:         localhost                 driver:       pdo_mysql                 server_version: 5.6 

see https://github.com/doctrine/doctrinebundle/issues/351#issuecomment-75456547


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -