From 0a95d97d7f452562bd1ef9960d956bc9448820c7 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 1 Apr 2017 16:31:18 -0400 Subject: [PATCH] Better support for redis as a backend --- app/Console/Commands/UpdateEnvironment.php | 29 ++++++++++++++++++++-- config/database.php | 12 +++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/Console/Commands/UpdateEnvironment.php b/app/Console/Commands/UpdateEnvironment.php index c9e1ea4e..ab56507f 100644 --- a/app/Console/Commands/UpdateEnvironment.php +++ b/app/Console/Commands/UpdateEnvironment.php @@ -41,6 +41,8 @@ class UpdateEnvironment extends Command {--dbuser=} {--dbpass=} {--url=} + {--driver=} + {--session-driver=} {--timezone=}'; /** @@ -126,8 +128,31 @@ class UpdateEnvironment extends Command $variables['APP_TIMEZONE'] = $this->option('timezone'); } - $variables['CACHE_DRIVER'] = 'memcached'; - $variables['SESSION_DRIVER'] = 'database'; + if (is_null($this->option('driver'))) { + $this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.'); + $variables['CACHE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', [ + 'memcached' => 'Memcache', + 'redis' => 'Redis (recommended)', + 'apc' => 'APC', + 'array' => 'PHP Array', + ], config('cache.default', 'memcached')); + } else { + $variables['CACHE_DRIVER'] = $this->option('driver'); + } + + if (is_null($this->option('session-driver'))) { + $this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.'); + $variables['SESSION_DRIVER'] = $this->choice('Which session driver backend would you like to use?', [ + 'database' => 'MySQL (recommended)', + 'redis' => 'Redis', + 'file' => 'File', + 'cookie' => 'Cookie', + 'apc' => 'APC', + 'array' => 'PHP Array', + ], config('session.driver', 'database')); + } else { + $variables['SESSION_DRIVER'] = $this->option('session-driver'); + } $bar = $this->output->createProgressBar(count($variables)); diff --git a/config/database.php b/config/database.php index 5a6e63f3..6f1057b5 100644 --- a/config/database.php +++ b/config/database.php @@ -45,7 +45,6 @@ return [ */ 'connections' => [ - 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), @@ -58,7 +57,6 @@ return [ 'prefix' => '', 'strict' => false, ], - ], /* @@ -86,15 +84,13 @@ return [ */ 'redis' => [ - - 'cluster' => false, - + 'client' => 'predis', 'default' => [ - 'host' => '127.0.0.1', - 'port' => 6379, + 'host' => env('REDIS_HOST', 'localhost'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', 6379), 'database' => 0, ], - ], ];