Laravel SDK

PHP / Composer client for calling Skryx Search from a Laravel app.

The Laravel SDK is a server-side PHP client tuned for typical Laravel patterns: container-bound, configurable via config/skryx.php, fluent query builder, automatic retries with exponential backoff.

# Install

composer require skryx/skryx-laravel

The package auto-registers a service provider — no manual provider edits needed.

# Configure

Publish the config:

php artisan vendor:publish --tag=skryx-config

Then add your API key to .env:

SKRYX_API_KEY=sk_live_xxxxxxxxxxxxxxxxxxxx
SKRYX_API_BASE=https://api.skryx.io

Use a search-scoped key (not an admin key) when the SDK is only reading; create one from your dashboard under API Keys.

# First query

use Skryx\Laravel\Facades\Skryx;

$results = Skryx::index('products')
    ->query('wireless headphones')
    ->filter('brand', 'Sony')
    ->facet('category')
    ->limit(20)
    ->search();

foreach ($results->hits() as $hit) {
    echo $hit['title']."\n";
}

echo "Total: ".$results->total()."\n";
echo "Facets: ".json_encode($results->facets())."\n";

# Indexing documents

Skryx::index('products')->upsert([
    ['id' => '42', 'title' => 'Sony WH-1000XM5', 'price' => 379],
    ['id' => '43', 'title' => 'Bose QC Ultra', 'price' => 449],
]);

For bulk imports of >1,000 records, use the batch endpoint via the SDK's ->batchUpsert(...) method — it chunks server-side, retries failed batches, and surfaces a summary.

# Error handling

The SDK throws Skryx\Laravel\Exceptions\SkryxException on API failures. Inspect the public code property for the canonical Skryx error code (e.g. SK-AI-503):

try {
    $results = Skryx::index('products')->query($q)->search();
} catch (\Skryx\Laravel\Exceptions\SkryxException $e) {
    Log::warning('Skryx failed', ['code' => $e->code, 'msg' => $e->getMessage()]);
    $results = collect();  // graceful fallback
}

See the Errors reference for the full code list.

# What this SDK is for vs the widget

  • Skryx Search Widget (cdn.skryx.io/widget.js) — browser-side autocomplete dropdown for your shoppers. Always use the widget for the customer-facing search UI.
  • Laravel SDK — for server-side or admin-side scenarios: bulk imports, custom search pages that need server-rendered results, cron-driven analytics, internal tools.

Most production stores use both — widget on the storefront, SDK in the backend.

# Versioning

The SDK follows semantic versioning. Major version bumps map to Skryx REST API major versions (/v1/, /v2/, …). Minor / patch bumps stay backward-compatible within the same major.

esc