PHPackages                             bradsearch/search-sync-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. bradsearch/search-sync-sdk

ActiveLibrary[API Development](/categories/api)

bradsearch/search-sync-sdk
==========================

PHP SDK for Brad Search synchronization API

v4.5.1(1mo ago)03.0k↓48%MITPHPPHP &gt;=8.4CI passing

Since Jun 19Pushed 1mo agoCompare

[ Source](https://github.com/Invertus/brad-search-php-sdk)[ Packagist](https://packagist.org/packages/bradsearch/search-sync-sdk)[ RSS](/packages/bradsearch-search-sync-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (66)Used By (0)

Brad Search Synchronization PHP SDK
===================================

[](#brad-search-synchronization-php-sdk)

A comprehensive PHP SDK for synchronizing data with the Brad Search API. This SDK provides type-safe field configuration, strict data validation, and robust error handling.

Requirements
------------

[](#requirements)

- PHP 8.4 or higher
- cURL extension
- JSON extension
- BCMath extension (required for ShopifyAdapter price comparisons)

Installation
------------

[](#installation)

```
composer require bradsearch/search-sync-sdk
```

Basic Usage
-----------

[](#basic-usage)

### 1. Configuration

[](#1-configuration)

```
use BradSearch\SyncSdk\Config\SyncConfig;
use BradSearch\SyncSdk\SynchronizationApiSdk;
use BradSearch\SyncSdk\Models\FieldConfigBuilder;

// Create configuration
$config = new SyncConfig(
    baseUrl: 'https://your-api-endpoint.com',
    authToken: 'your-auth-token',
    timeout: 30,
    verifySSL: true
);

// Define field configuration
$fieldConfiguration = FieldConfigBuilder::ecommerceFields();
// Or build custom fields:
// $fieldConfiguration = [
//     'title' => FieldConfigBuilder::textKeyword(),
//     'price' => FieldConfigBuilder::keyword(),
//     'categories' => FieldConfigBuilder::hierarchy(),
// ];

// To add custom fields or override existing default ecommerce field config with custom values:
// $variants = ['material'];
// #fieldConfiguration = FieldConfigBuilder::addToEcommerceFields($variants);

// Initialize SDK
$syncSdk = new SynchronizationApiSdk($config, $fieldConfiguration);
```

### 2. Index Management

[](#2-index-management)

```
// Create an index
$syncSdk->createIndex('my-product-index');

// Create an index with locales
$syncSdk->createIndex('my-product-index', ['en', 'fr', 'de']);

// Delete an index
$syncSdk->deleteIndex('my-product-index');
```

### 3. Product Synchronization

[](#3-product-synchronization)

#### Single Product

[](#single-product)

```
$product = [
    'id' => 'product-123',
    'name' => 'Premium T-Shirt',
    'brand' => 'BrandName',
    'sku' => 'TSH-001',
    'categoryDefault' => 'Clothing > T-Shirts',
    'categories' => [
        'Clothing',
        'Clothing > T-Shirts',
        'Clothing > T-Shirts > Premium'
    ],
    'variants' => [
        [
            'id' => 'variant-1',
            'sku' => 'TSH-001-S-RED',
            'attributes' => [
                'size' => 'S',
                'color' => 'Red'
            ]
        ]
    ],
    'imageUrl' => [
        'small' => 'https://example.com/image-small.jpg',
        'medium' => 'https://example.com/image-medium.jpg'
    ],
    'productUrl' => 'https://shop.example.com/products/premium-tshirt'
];

$syncSdk->sync('my-product-index', $product);
```

#### Bulk Synchronization

[](#bulk-synchronization)

```
$products = [
    // ... array of product data
];

// Sync with default batch size (100)
$syncSdk->syncBulk('my-product-index', $products);

// Sync with custom batch size
$syncSdk->syncBulk('my-product-index', $products, 50);
```

Field Types
-----------

[](#field-types)

The SDK supports the following field types:

- `TEXT_KEYWORD`: Full-text search with keyword matching
- `TEXT`: Full-text search only
- `KEYWORD`: Exact keyword matching
- `HIERARCHY`: Hierarchical categories
- `VARIANTS`: Product variants with attributes
- `IMAGE_URL`: Image URLs object with size keys (e.g., `{"small": "url", "medium": "url"}`)
- `URL`: Regular URLs with validation

Custom Field Configuration
--------------------------

[](#custom-field-configuration)

```
use BradSearch\SyncSdk\Models\FieldConfig;
use BradSearch\SyncSdk\Models\FieldConfigBuilder;
use BradSearch\SyncSdk\Enums\FieldType;

$customFields = [
    'title' => FieldConfigBuilder::textKeyword(),
    'description' => FieldConfigBuilder::text(),
    'price' => FieldConfigBuilder::keyword(),
    'categories' => FieldConfigBuilder::hierarchy(),
    'website' => FieldConfigBuilder::url(),
    'image' => FieldConfigBuilder::imageUrl(),
    'variants' => FieldConfigBuilder::variants([
        'size' => FieldConfigBuilder::keyword(),
        'color' => FieldConfigBuilder::keyword(),
        'material' => FieldConfigBuilder::textKeyword(),
    ]),
];

// Or create manually
$customFields = [
    'title' => new FieldConfig(FieldType::TEXT_KEYWORD),
    'variants' => new FieldConfig(
        type: FieldType::VARIANTS,
        attributes: [
            'size' => new FieldConfig(FieldType::KEYWORD),
            'color' => new FieldConfig(FieldType::KEYWORD),
        ]
    ),
];
```

Data Validation
---------------

[](#data-validation)

The SDK provides strict data validation:

```
// Validate a single product
try {
    $syncSdk->validateProduct($product);
    echo "Product is valid!";
} catch (ValidationException $e) {
    echo "Validation errors:\n";
    foreach ($e->errors as $error) {
        echo "- $error\n";
    }
}

// Validate multiple products
try {
    $syncSdk->validateProducts($products);
} catch (ValidationException $e) {
    // Handle validation errors
}
```

Error Handling
--------------

[](#error-handling)

The SDK uses typed exceptions for different error scenarios:

```
use BradSearch\SyncSdk\Exceptions\ApiException;
use BradSearch\SyncSdk\Exceptions\ValidationException;
use BradSearch\SyncSdk\Exceptions\InvalidFieldConfigException;

try {
    $syncSdk->sync('my-index', $product);
} catch (ValidationException $e) {
    // Data validation failed
    echo "Validation errors: " . implode(', ', $e->errors);
} catch (ApiException $e) {
    // API request failed
    echo "API error {$e->statusCode}: {$e->getMessage()}";
    echo "Response: {$e->responseBody}";
} catch (InvalidFieldConfigException $e) {
    // Field configuration is invalid
    echo "Configuration error: {$e->getMessage()}";
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Field Filtering

[](#field-filtering)

The SDK automatically filters product data to only include fields defined in the configuration. This ensures clean data and prevents sending unnecessary fields to the API.

### Batch Processing

[](#batch-processing)

Large datasets are automatically processed in batches to avoid memory issues and API limits:

```
// Process 10,000 products in batches of 50
$syncSdk->syncBulk('my-index', $largeProductArray, 50);
```

### Getting Field Configuration

[](#getting-field-configuration)

```
$fields = $syncSdk->getFieldConfiguration();
foreach ($fields as $name => $config) {
    echo "Field: $name, Type: {$config->type->value}\n";
}
```

Testing
-------

[](#testing)

The SDK includes comprehensive validation and error handling. For testing:

1. Use the validation methods to check data before syncing
2. Start with small batches to verify configuration
3. Monitor API responses for any issues

License
-------

[](#license)

MIT License

Support
-------

[](#support)

For support and bug reports, please create an issue in the repository.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 59.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

47

Last Release

53d ago

Major Versions

v1.7.0 → v2.0.02025-09-10

v2.3.0 → v3.0.02025-09-29

v3.12.2 → v4.0.02026-02-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/164f4bdc2431cf6777fcf5dc006bba77b7dc3a6d60e513680af8aebcc5d90649?d=identicon)[StanislovasRamanauskas](/maintainers/StanislovasRamanauskas)

![](https://www.gravatar.com/avatar/d5769761f1132363f8ce1217c19743e5addaaa82fe234381aa9b08dc560725f4?d=identicon)[bradcommerce](/maintainers/bradcommerce)

![](https://www.gravatar.com/avatar/8f293f546706438fc943fe5563646acf932142107e7923e6356ef9126ec93696?d=identicon)[ekunigonis](/maintainers/ekunigonis)

![](https://www.gravatar.com/avatar/69c46d53e1d58a8b30221b0b6c1dc9b2739acfb4c89f92dce26dabc4f8219978?d=identicon)[SteponasInvertus](/maintainers/SteponasInvertus)

---

Top Contributors

[![tomas862](https://avatars.githubusercontent.com/u/17051250?v=4)](https://github.com/tomas862 "tomas862 (164 commits)")[![SteponasK](https://avatars.githubusercontent.com/u/132608893?v=4)](https://github.com/SteponasK "SteponasK (71 commits)")[![egidijuskunigonis](https://avatars.githubusercontent.com/u/190341767?v=4)](https://github.com/egidijuskunigonis "egidijuskunigonis (30 commits)")[![ignas585](https://avatars.githubusercontent.com/u/201629027?v=4)](https://github.com/ignas585 "ignas585 (7 commits)")[![PauliusInvertus](https://avatars.githubusercontent.com/u/200574866?v=4)](https://github.com/PauliusInvertus "PauliusInvertus (5 commits)")

---

Tags

apisearchelasticsearchopensearchsync

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bradsearch-search-sync-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/bradsearch-search-sync-sdk/health.svg)](https://phpackages.com/packages/bradsearch-search-sync-sdk)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[gigablah/sphinxphp

Sphinx Search PHP 5.3+ API with PSR compliance

861.4M16](/packages/gigablah-sphinxphp)[gigablah/fsphinxphp

Facet extension for Sphinx Search

5362.8k](/packages/gigablah-fsphinxphp)[hmerritt/imdb-api

IMDB API that can fetch film data and search results

6911.3k](/packages/hmerritt-imdb-api)[sehrling/elasticsuite-ghost-cleaner

Magento 2 module to delete ghost indices automatically for the Smile Elasticsuite module

1789.0k](/packages/sehrling-elasticsuite-ghost-cleaner)[mikemadisonweb/yii2-elasticsearch

Yii2 extension for integration with Elasticsearch version 5.0 and above.

153.9k](/packages/mikemadisonweb-yii2-elasticsearch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
