content/develop/clients/php/_index.md
Predis is the recommended PHP
client for Redis.
The sections below explain how to install Predis and connect your application to a Redis database.
{{< note >}}Although we provide basic documentation for Predis, it is a third-party
client library and is not developed or supported directly by Redis.
{{< /note >}}
Predis requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
Use Composer to install the Predis library
with the following command line:
composer require predis/predis
Connect to a locally-running server on the standard port (6379) with the following code:
{{< clients-example set="landing" step="connect" lang_filter="PHP" description="Foundational: Connect to a Redis server and establish a client connection" difficulty="beginner" >}} {{< /clients-example >}}
Store and retrieve a simple string to test the connection:
{{< clients-example set="landing" step="set_get_string" lang_filter="PHP" description="Foundational: Set and retrieve string values using SET and GET commands" difficulty="beginner" >}} {{< /clients-example >}}
Store and retrieve a [hash]({{< relref "/develop/data-types/hashes" >}}) object:
{{< clients-example set="landing" step="set_get_hash" lang_filter="PHP" description="Foundational: Store and retrieve hash data structures using HSET and HGETALL" difficulty="beginner" >}} {{< /clients-example >}}
The Predis wiki on Github has information about the different connection options you can use.
See also the pages in this section for more information and examples: