---
title: Dependencies and Auto-Discovery
slug: php-sdk/dependencies
docTags: 
createdAt: 2024-05-15T08:34:33.971Z
---

The PHP-SDK is designed to be as interoperable as possible. As such, dependencies on third party libraries - especially where alternatives exist - is kept to a minimum, and required versions kept as loose as possible.

## Existing Dependencies

| Package                                   | Details                                                                                                                                                                                          |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `php`                                     | All [currently maintained (including security support) PHP versions](https://www.php.net/supported-versions.php) are supported.                                                                  |
| `ext-libxml`<br />`ext-simplexml`         | XML handling libraries are required to process the response payload of some Klevu APIs                                                                                                           |
| `psr/log`                                 | Allows hooking in [PSR-3 compliant logging](https://www.php-fig.org/psr/psr-3/)                                                                                                                  |
| `psr/http-client`<br />`psr/http-message` | Allows hooking in [PSR-17 compliant HTTP factories](https://www.php-fig.org/psr/psr-17/) and [PSR-18 compliant HTTP clients](https://www.php-fig.org/psr/psr-18/) to communicate with Klevu APIs |
| `php-http/discovery`                      | Provides auto-discovery functionality for compatible HTTP clients and factories already installed in your application                                                                            |

## Auto-Discovery

### HTTP Client, Request and Response Factories

In order to reduce installation time in applications which already have a PSR-18 compliant HTTP client, such as Guzzle, any class which needs to communicate with the Klevu APIs will attempt to automatically discover a suitable client for transport. This action occurs during object instantiation and will throw an exception if a class cannot be found.
If your application uses a non-PSR-18 compliant library or PHP's curl functions directly, you will need to install or create a client which implements `Psr\Http\Client\ClientInterface` and ensure they are available to your autoloader.

The HTTP Discovery package will also attempt to locate factory classes responsible for creating PSR-17-compliant Request and Response objects.
If your application does not contain these factories, you will need to install or create classes which implement `Psr\Http\Message\RequestFactoryInterface` and `Psr\Http\Message\ResponseFactoryInterface` and ensure they are available to your autoloader.

:::hint{type="info"}
If automatic discovery cannot locate implementations of any of the above classes, or you wish to use a different class to the one found, all service classes will allow injection of the relevant classes through the constructor.
:::

For more information and examples, please see the [Configure HTTP Transport](docId\:Waa8UvHYbJ_om0CYK00EA) How-To article.

### Logging

As logging is not an integral component of the SDK, it will not attempt auto-discovery for implementations of `Psr\Log\LoggerInterface` . In this scenario, no errors will be raised - logging will be silently skipped.&#x20;

To enable logging, you should install or create an implementation of a PSR-3 compliant logger and inject it manually into the applicable classes.&#x20;

For more information and examples, please see the [Logging](docId\:He6HsiAm09aDhe9F0iNsH) How-To article.
