/ Laravel

Using Redis cache with Laravel Lumen 2.5

Out of the box Lumen doesn’t work with Redis for caching. I met errors such as class redis does not exist along with other errors. Here is a quick way to get Redis working with your cache in Lumen 2.5.

First you need to add two packages to your composer.json

"predis/predis": "^1.0",
"illuminate/redis": "^5.2"

then run your

composer update

and this will install the packages needed to work with Redis.

The final piece of the puzzle is you have to register the service yourself in

bootstrap/app.php

Just add

$app->register('Illuminate\Redis\RedisServiceProvider');

To use the Cache facade you'll need to uncomment the

$app->withFacades();

line in bootstrap/app.php.

Then add

use Cache;

in your controller and this should allow you to now use Redis in your Lumen 2.5 app.

Using Redis cache with Laravel Lumen 2.5
Share this

Subscribe to Dan Rovito