Download the PHP package klevu/php-sdk without Composer
On this page you can find all versions of the php package klevu/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download klevu/php-sdk
More information about klevu/php-sdk
Files in klevu/php-sdk
Informations about the package php-sdk
klevu/php-sdk
The Klevu PHP-SDK is a small package designed to simplify communicating with Klevu API services.
Getting Started
- Create an account with Klevu.
Free trial, with full access to all features is available. - Retrieve your JS API Key and REST AUTH Key from Store Settings > Store Info in your account.
-
Install the SDK in your application using composer.
- Start building!
There are some quick-start examples below, as well as detailed guides in our developer documentation.
System Requirements
To use this library, you must be running PHP 8.1 compiled with the libxml
and simplexml
extensions.
See the PHP docs for more information.
You will also require a PSR-18 compatible HTTP client, such as guzzlehttp/guzzle
,
which provides psr/http-client-implementation
support.
A list of compatible libraries can be found on Packagist.
We also recommend a PSR-3 compatible logger library, such as monolog/monolog
.
This will allow the SDK to write activity it performs to a location of your choice.
Quick Start Guide
Account Credentials
The AccountCredentials object is required by all services connecting with Klevu.
You will need both your JS API Key (in the format klevu-xxxxxxx
) and your REST AUTH Key from your Klevu account.
When saving and accessing these credentials within your application, please treat the REST AUTH Key in the same manner as any other sensitive information, such as passwords.
If you need to change your REST AUTH Key, please contact our support team.
Create a new Klevu\PhpSDK\Model\AccountCredentials
object. Note, account credentials objects are immutable.
Retrieving Account Details
You can find a more complete example of retrieving account information in the examples section
The AccountLookupService lets you retrieve details about your Klevu account, including hostnames required to push and pull data to other services.
Which will return an object as follows.
Each property listed is private and accessed through getters, as follows
Note, in the example above we instantiate the service implementation rather than the interface.
If you are using dependency injection, we recommend configuring theKlevu\PhpSDK\Api\Interface\Service\Account\AccountLookupService
interface toKlevu\PhpSDK\Service\Account\AccountLookupService
, along with any constructor arguments.
For example:
Retrieving Account Features
In the example above, the returned model's accountFeatures
property is empty. In order to load your account's
enabled features, you will need to invoke the
AccountFeaturesService, as shown.
Which will return an immutable object as follows.
Each property is public and can be accessed directly, but not modified.
You can also attach this to your loaded account model by setting the accountFeatures
property. This is not required
but you may find it useful to have all data in a single model within your application.
Note: as with the previous example, we instantiated the implementation rather than the interface in our example. Again, we recommend mapping with dependency injection if your application supports this.
All versions of php-sdk with dependencies
ext-libxml Version *
ext-simplexml Version *
psr/log Version *
psr/http-client Version *
psr/http-message Version *
php-http/discovery Version ~1.15
linchpin/phpdocumentor-template-markdown Version ^1.0