PHP code example of getjoystick / joystick-php

1. Go to this page and download the library: Download getjoystick/joystick-php 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/ */

    

getjoystick / joystick-php example snippets




$config = \Joystick\ClientConfig::create()->setApiKey(getenv('JOYSTICK_API_KEY'));

$client = \Joystick\Client::create($config);

$getContentsResponse = $client->getContents(['content-id1', 'content-id2']);

$getContentsResponse->myProperty1
$getContentsResponse->myProperty2

$getContentResponse = $client->getContent('content-id1');
$getContentResponse->myProperty1

$config = \Joystick\ClientConfig::create()
    ->setApiKey(getenv('JOYSTICK_API_KEY'))
    ->setCacheExpirationSeconds(600) // 10 mins
    ->setSerialized(true)
    ->setParams([
        'param1' => 'value1',
        'param2' => 'value2',
     ])
     ->setSemVer('0.0.1')
     ->setUserId('user-id-1');

$getContentResponse = $client->getContent('content-id1', ['fullResponse' => true]);
// OR
$getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['fullResponse' => true]);

$getContentResponse = $client->getContent('content-id1', ['serialized' => true]);
// OR
$getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['serialized' => true]);

$getContentResponse = $client->getContent('content-id1', ['refresh' => true]);
// OR
$getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['refresh' => true]);

$config = \Joystick\ClientConfig::create()
    ->setApiKey(getenv('JOYSTICK_API_KEY'))
    ->setSerialized(true)
bash
composer