-
-
Save mashud-rana/918d4b3798167937e24c5dde63d287df 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment