diff --git a/data/infra/php.Dockerfile b/data/infra/php.Dockerfile index c2348cc2..28d9d6f3 100644 --- a/data/infra/php.Dockerfile +++ b/data/infra/php.Dockerfile @@ -35,6 +35,18 @@ RUN docker-php-ext-configure redis\ # cleanup RUN rm /tmp/phpredis.tar.gz +# Install memcached extension +RUN apk add --no-cache --virtual cyrus-sasl-dev +RUN apk add --no-cache --virtual libmemcached-dev +ADD https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz /tmp/memcached.tar.gz +RUN mkdir -p /usr/src/php/ext/memcached\ + && tar xf /tmp/memcached.tar.gz -C /usr/src/php/ext/memcached --strip-components=1 +# configure and install +RUN docker-php-ext-configure memcached\ + && docker-php-ext-install memcached +# cleanup +RUN rm /tmp/memcached.tar.gz + # Install APCu extension ADD https://pecl.php.net/get/apcu-5.1.3.tgz /tmp/apcu.tar.gz RUN mkdir -p /usr/src/php/ext/apcu\ diff --git a/module/CLI/src/Command/Install/InstallCommand.php b/module/CLI/src/Command/Install/InstallCommand.php index 1271e2ea..cdee0cb0 100644 --- a/module/CLI/src/Command/Install/InstallCommand.php +++ b/module/CLI/src/Command/Install/InstallCommand.php @@ -272,6 +272,12 @@ class InstallCommand extends Command $config['entity_manager']['connection']['user'] = $params['DATABASE']['USER']; $config['entity_manager']['connection']['password'] = $params['DATABASE']['PASSWORD']; $config['entity_manager']['connection']['dbname'] = $params['DATABASE']['NAME']; + + if ($params['DATABASE']['DRIVER'] === 'pdo_mysql') { + $config['entity_manager']['connection']['driverOptions'] = [ + \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', + ]; + } } return $config; diff --git a/module/CLI/test/Command/Install/InstallCommandTest.php b/module/CLI/test/Command/Install/InstallCommandTest.php index 846a083b..ebe1874f 100644 --- a/module/CLI/test/Command/Install/InstallCommandTest.php +++ b/module/CLI/test/Command/Install/InstallCommandTest.php @@ -47,8 +47,8 @@ class InstallCommandTest extends TestCase protected function createInputStream() { - $stream = fopen('php://memory', 'r+', false); - fputs($stream, <<configWriter->toFile(Argument::any(), [ 'app_options' => [ @@ -81,6 +81,9 @@ CLI_INPUT 'dbname' => 'shlink_db', 'user' => 'alejandro', 'password' => '1234', + 'driverOptions' => [ + \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', + ] ], ], 'translator' => [