page_type | languages | name | description | products | |||
---|---|---|---|---|---|---|---|
sample |
|
Quickstart: Use Azure Cache for Redis in PHP |
Learn how to interact with Azure Cache for Redis in your PHP app. |
|
This sample helps to understand how to interact with Azure Cache for Redis in your PHP application. See the accompanying article on the documentation site for details, including best practices and how to create the sample code from scratch.
- Azure subscription - create one for free.
- PHP >= 7.2 - download here.
Predis is an open-source client supported by Redis organization.
Predis client available on packagist.org and distributed with Composer dependency manager. You can download Composer here.
To get Predis with Composer, simply run:
composer require predis/predis
Predis source-code also available on GitHub repository. Feel free to check README for more information about Predis.
Before you run a sample script, you need to set up a Redis host and password. This values represented by following environment variables:
export REDIS_HOST=your_redis_host
export REDIS_PASSWORD=your_redis_password
After the previous steps you can run sample script from the repository root directory like this:
php quickstart/php/test.php