neuronsearchlab / sdk-php
Official PHP SDK for accessing NeuronSearchLab APIs
Package info
github.com/NeuronSearchLab/neuronsearchlab-sdk-php
pkg:composer/neuronsearchlab/sdk-php
dev-main
2026-04-05 20:49 UTC
Requires
- php: ^8.4
This package is auto-updated.
Last update: 2026-04-05 20:50:03 UTC
README
Official PHP SDK for the NeuronSearchLab API. It exposes a single NeuronSDK class (track events, upsert items, patch and delete items, request recommendations) plus configureLogger() for opt-in diagnostic output.
Installation
composer require neuronsearchlab/sdk-php
Quick start
<?php require __DIR__ . '/vendor/autoload.php'; use NeuronSearchLab\NeuronSDK; use function NeuronSearchLab\configureLogger; configureLogger(['level' => 'INFO']); $sdk = new NeuronSDK([ 'baseUrl' => 'https://api.neuronsearchlab.com', 'accessToken' => getenv('NEURON_API_TOKEN'), 'collateWindowSeconds' => 3, 'maxBatchSize' => 200, 'maxBufferedEvents' => 5000, ]); $contentId = 3187; $sdk->trackEvent([ 'eventId' => 1, 'userId' => '42', 'itemId' => $contentId, 'metadata' => ['action' => 'view'], ])->wait(); $sdk->upsertItem([ 'itemId' => $contentId, 'name' => 'Premier League Highlights', 'description' => 'Matchday recap', 'metadata' => ['league' => 'EPL'], ]); $sdk->patchItem(['itemId' => $contentId, 'active' => true]); $sdk->deleteItems(['itemId' => $contentId]); $recs = $sdk->getRecommendations(['userId' => '42', 'limit' => 5]);
Notes
- The package now targets PHP 8.4+.
- PHP does not have browser lifecycle hooks, so event batching is process-local. Buffered events flush when
flushEvents()is called, when the batch limit is reached, when an older buffer exceeds the collate window on a latertrackEvent(), or automatically at shutdown. trackEvent()returns aPendingResult; call->wait()to force delivery and surface any transport error immediately.- Request ID propagation, session ID handling, array-batch fallback, and retry behavior mirror the TypeScript SDK as closely as PHP’s synchronous runtime allows.
Release Flow
- CI runs on pushes and pull requests against PHP 8.4.
- Packagist is already connected to the GitHub repository and auto-updates from pushes.
- Pushes to
mainrefreshdev-mainon Packagist, and pushedv*git tags become installable versioned releases. .github/workflows/publish.ymlruns validation and tests on tag pushes before or alongside those releases.
License
MIT