Created
April 23, 2021 02:24
-
-
Save lnfel/ab04028d6b115304ca5daef145710ac0 to your computer and use it in GitHub Desktop.
Laravel 8 Redis setup on Windows with xampp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Laravel 8 Redis setup on Windows with xampp | |
Note: test done using windows 7 | |
1. Install predis on your project | |
https://laravel.com/docs/8.x/redis#introduction | |
composer require predis/predis | |
- un-comment 'Redis' => Illuminate\Support\Facades\Redis::class, in your config/app.php | |
- on your .env make sure you have the following variables: | |
REDIS_CLIENT=predis | |
REDIS_PORT=6379 | |
2. Download php_redis.dll on pecl | |
https://pecl.php.net/package/redis | |
- extract the zip file and move php_redis.dll to your xampp php ext folder | |
- usually is at C:\xampp\php\ext | |
- edit C:\xampp\php\php.ini and make sure it has the extension enabled or add the following line: | |
[Redis] | |
extension=php_redis.dll | |
3. Download or install Redis-x64-3.2.100 for Windows | |
https://github.com/MicrosoftArchive/redis/releases/ | |
- if your downloaded the zip don't forget to add the path to your environment variables | |
4. Restart xampp server | |
- make sure APP_DEBUG=true in your .env to see any errors | |
- refresh your laravel config by running the following commands | |
php artisan config:clear | |
php artisan config:cache | |
5. Test the following code in your controller | |
use Redis; | |
class YourController extends Controller | |
{ | |
public function index() | |
{ | |
$redis = new Redis(); | |
$redis->connect('localhost', 6379); | |
$redis->set('user', 'John Doe'); | |
$value = $redis->get('user'); | |
dd($value); | |
} | |
} | |
- you should see the output "John Doe" when browsing the app on localhost |
i got this error
No connection could be made because the target machine actively refused it [tls://127.0.0.1:6380]
Config/database.php
'redis' => [
'client' => 'predis',
'default' => [
'scheme' => 'unix',
//'path' => '/var/run/redis/redis.sock'
// 'host' => env('REDIS_HOST', '127.0.0.1'),
// 'password' => env('REDIS_PASSWORD', null),
// 'port' => env('REDIS_PORT', 6379),
// 'database' => 0,
// 'unix-socket' => '/var/run/redis/redis.sock'
],
Problem with 'Path' on Windows.
Missing UNIX domain socket path.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I have this error
Call to undefined method Illuminate\Support\Facades\Redis::connect()