Skip to content

Commit 0a95d97

Browse files
committed
Better support for redis as a backend
1 parent cbeecfe commit 0a95d97

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

app/Console/Commands/UpdateEnvironment.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class UpdateEnvironment extends Command
4141
{--dbuser=}
4242
{--dbpass=}
4343
{--url=}
44+
{--driver=}
45+
{--session-driver=}
4446
{--timezone=}';
4547

4648
/**
@@ -126,8 +128,31 @@ public function handle()
126128
$variables['APP_TIMEZONE'] = $this->option('timezone');
127129
}
128130

129-
$variables['CACHE_DRIVER'] = 'memcached';
130-
$variables['SESSION_DRIVER'] = 'database';
131+
if (is_null($this->option('driver'))) {
132+
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
133+
$variables['CACHE_DRIVER'] = $this->choice('Which cache driver backend would you like to use?', [
134+
'memcached' => 'Memcache',
135+
'redis' => 'Redis (recommended)',
136+
'apc' => 'APC',
137+
'array' => 'PHP Array',
138+
], config('cache.default', 'memcached'));
139+
} else {
140+
$variables['CACHE_DRIVER'] = $this->option('driver');
141+
}
142+
143+
if (is_null($this->option('session-driver'))) {
144+
$this->line('If you chose redis as your cache driver backend, you *must* have a redis server configured already.');
145+
$variables['SESSION_DRIVER'] = $this->choice('Which session driver backend would you like to use?', [
146+
'database' => 'MySQL (recommended)',
147+
'redis' => 'Redis',
148+
'file' => 'File',
149+
'cookie' => 'Cookie',
150+
'apc' => 'APC',
151+
'array' => 'PHP Array',
152+
], config('session.driver', 'database'));
153+
} else {
154+
$variables['SESSION_DRIVER'] = $this->option('session-driver');
155+
}
131156

132157
$bar = $this->output->createProgressBar(count($variables));
133158

config/database.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
*/
4646

4747
'connections' => [
48-
4948
'mysql' => [
5049
'driver' => 'mysql',
5150
'host' => env('DB_HOST', 'localhost'),
@@ -58,7 +57,6 @@
5857
'prefix' => '',
5958
'strict' => false,
6059
],
61-
6260
],
6361

6462
/*
@@ -86,15 +84,13 @@
8684
*/
8785

8886
'redis' => [
89-
90-
'cluster' => false,
91-
87+
'client' => 'predis',
9288
'default' => [
93-
'host' => '127.0.0.1',
94-
'port' => 6379,
89+
'host' => env('REDIS_HOST', 'localhost'),
90+
'password' => env('REDIS_PASSWORD', null),
91+
'port' => env('REDIS_PORT', 6379),
9592
'database' => 0,
9693
],
97-
9894
],
9995

10096
];

0 commit comments

Comments
 (0)