PHP code example of neuronsearchlab / sdk-php
1. Go to this page and download the library: Download neuronsearchlab/sdk-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/ */
neuronsearchlab / sdk-php example snippets
euronSearchLab\NeuronSDK;
use function NeuronSearchLab\configureLogger;
configureLogger(['level' => 'INFO']);
$sdk = new NeuronSDK([
'baseUrl' => 'https://api.neuronsearchlab.com/v1',
'accessToken' => getenv('NEURON_API_TOKEN'),
'collateWindowSeconds' => 3,
'maxBatchSize' => 200,
'maxBufferedEvents' => 5000,
]);
$itemId = 'item-3187';
$sdk->trackEvent([
'type' => 'view',
'userId' => '42',
'itemId' => $itemId,
'metadata' => ['action' => 'view'],
])->wait();
$sdk->upsertItem([
'id' => $itemId,
'name' => 'Premier League Highlights',
'description' => 'Matchday recap',
'metadata' => ['league' => 'EPL'],
]);
$sdk->patchItem(['itemId' => $itemId, 'active' => true]);
$sdk->deleteItems(['itemId' => $itemId]);
$recs = $sdk->getRecommendations([
'userId' => '42',
'contextId' => 'homepage',
'limit' => 5,
]);
$results = $sdk->search([
'query' => 'latest football highlights',
'userId' => '42',
'contextId' => 'homepage',
'limit' => 5,
'filter' => ['category:sports'],
]);
bash
composer