安裝 Predis
# 移至 laravel 資料夾內
$ composer require predis/predis
config
.env
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
Code
- build controller
$ php artisan make:controller TestRedis
- controller
app\Http\Controllers\TestRedis.php
use Redis;
class TestRedis extends Controller
{
public function show()
{
echo Redis::PING(); // PONG
}
}
Docs
Laravel
Redis
- Command:https://redis.io/commands