Docs
PHP
Predis and Laravel (cache, sessions and queues).
Each example reads the connection URL from VALKEY_URL; copy it from your instance page in the dashboard. See connection details and limits for what applies to every client.
On this page: Predis · Laravel
Predis
Use the tls scheme and the parts of the connection URL.
Install
composer require predis/predisindex.php
<?phprequire 'vendor/autoload.php'; $client = new Predis\Client([ 'scheme' => 'tls', 'host' => getenv('VALKEY_HOST'), // inst-<id>.eu.kvnest.com 'port' => 6380, 'username' => 'default', 'password' => getenv('VALKEY_PASSWORD'),]); $client->setex('greeting', 60, 'hello');echo $client->get('greeting');Laravel
Use the Predis client and add a scheme option to the default and cache connections in config/database.php, so TLS can be switched on from .env.
Install
composer require predis/predis.env
REDIS_CLIENT=predisREDIS_SCHEME=tlsREDIS_HOST=inst-<id>.eu.kvnest.comREDIS_PORT=6380REDIS_USERNAME=defaultREDIS_PASSWORD=<password> CACHE_STORE=redisSESSION_DRIVER=redisQUEUE_CONNECTION=redisconfig/database.php
<?php return [ // ... 'redis' => [ 'client' => env('REDIS_CLIENT', 'phpredis'), 'default' => [ 'scheme' => env('REDIS_SCHEME', 'tcp'), 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'username' => env('REDIS_USERNAME'), 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => env('REDIS_DB', '0'), ], 'cache' => [ 'scheme' => env('REDIS_SCHEME', 'tcp'), // ...same keys as default, with REDIS_CACHE_DB ], ],];Starter evicts keys when memory is full (allkeys-lru), which can silently drop jobs. Use it for experiments; production queues need a persistent plan with noeviction (Casual or Pro, coming soon).