PHP code example of logshub / search-client-php

1. Go to this page and download the library: Download logshub/search-client-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/ */

    

logshub / search-client-php example snippets



u can find your service's details on your logshub.com dashboard.
$location = 'uk01';
$serviceId = '5b5a06d2-23bc-4186-4d1b-3a17bfa7200d';
$apihash = 'xizinISDPH';
$apiSecret = 'ZJLnvZAujIBOTiJVyfImZYLEKdesJPKUntfFztYLiefQsCMgmd';
$client = \Logshub\SearchClient\Client::fromLocation(
   $location, $apihash, $apiSecret);

$product = new \Logshub\SearchClient\Model\Product('1', [
   'name' => 'Laptop Full HD 8GB RAM',
   'price' => 899
]);
$request = new \Logshub\SearchClient\Request\IndexProducts($serviceId, [
   $product
]);
$response = $client->indexProducts($request);

echo $response->getBody() . PHP_EOL;