Project Setup
To get started, let’s create a new Laravel application. If you don’t have the Laravel CLI installed globally, install it first using Composer:Database Setup
Create a Redis database using Upstash Console. Go to the Connect to your database section and click on Laravel. Copy those values into your .env file:.env
Framework Integration
Upstash Redis integrates seamlessly with Laravel, allowing it to be used as a driver for multiple framework components.Interact with Redis
The Redis Facade in Laravel provides a convenient way to interact with your Redis database. For example:Cache
To use Upstash Redis as your caching driver, update the CACHE_STORE in your .env file:.env
Session
Laravel can store session data in Upstash Redis. To enable this, set the SESSION_DRIVER in your .env file:.env
Queue
Upstash Redis can also serve as a driver for Laravel’s queue system, enabling job processing. To configure this, update the QUEUE_CONNECTION in your .env file:.env