PHP code example of klevu / php-sdk

1. Go to this page and download the library: Download klevu/php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

klevu / php-sdk example snippets




declare(strict_types=1);

// Include the composer autoloader - you may need to change the directory path
 JS API Key]',
    restAuthKey: '[Your REST AUTH KEY]',
);



declare(strict_types=1);

// Include the composer autoloader - you may need to change the directory path
kupService = new AccountLookupService();
$accountCredentials = new AccountCredentials(
    jsApiKey: '[Your JS API Key]',
    restAuthKey: '[Your REST AUTH KEY]',
);

$account = $accountLookupService->execute($accountCredentials);

var_export($account);

$account->getJsApiKey();

$accountLookupService = $container->get(\Klevu\PhpSDK\Api\Service\Account\AccountLookupServiceInterface::class);



declare(strict_types=1);

// Include the composer autoloader - you may need to change the directory path
eaturesService = new AccountFeaturesService();
$accountCredentials = new AccountCredentials(
    jsApiKey: '[Your JS API Key]',
    restAuthKey: '[Your REST AUTH KEY]',
);

$accountFeatures = $accountFeaturesService->execute($accountCredentials);

var_export($account);

$account->setAccountFeatures($accountFeatures);

var_export($account);

composer 
text
Klevu\PhpSDK\Model\Account\AccountFeatures::__set_state(array(
   'smartCategoryMerchandising' => true,
   'smartRecommendations' => true,
   'preserveLayout' => true,
))