flapjackhq / flapjack-search-php
A fully-featured and blazing-fast PHP API client to interact with Flapjack Search. Drop-in replacement for algoliasearch-client-php.
dev-main
2026-02-10 02:27 UTC
Requires
- php: >=8.1 !=8.3.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/psr7: ^2.0
- psr/http-message: ^1.1 || ^2.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- psr/simple-cache: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.91.3
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^10.0
- vlucas/phpdotenv: ^5.4
Suggests
- guzzlehttp/guzzle: If you prefer to use Guzzle HTTP client instead of the Http Client implementation provided by the package
This package is auto-updated.
Last update: 2026-04-10 04:27:40 UTC
README
A fully-featured and blazing-fast PHP API client for Flapjack Search. Drop-in replacement for the Algolia PHP client.
Installation
composer require flapjackhq/flapjack-search-php:0.1.0-beta.1
Quick Start
use Flapjack\FlapjackSearch\Api\SearchClient; use Flapjack\FlapjackSearch\Configuration\SearchConfig; // Flapjack Cloud $client = SearchClient::create('YOUR_APP_ID', 'YOUR_API_KEY'); // Self-hosted Flapjack $config = SearchConfig::create('YOUR_APP_ID', 'YOUR_API_KEY'); $config->setFullHosts([ ['url' => 'localhost:7700', 'accept' => 3, 'protocol' => 'http'], ]); $client = SearchClient::createWithConfig($config);
Usage
Index Objects
$objects = [ ['objectID' => '1', 'name' => 'iPhone 15', 'brand' => 'Apple', 'price' => 999], ['objectID' => '2', 'name' => 'Galaxy S24', 'brand' => 'Samsung', 'price' => 799], ]; $response = $client->saveObjects('products', $objects);
Search
// Basic search $response = $client->search([ 'requests' => [ ['indexName' => 'products', 'query' => 'iphone'], ], ]); // Search with filters and facets $response = $client->search([ 'requests' => [ [ 'indexName' => 'products', 'query' => 'phone', 'filters' => 'brand:Apple', 'facets' => ['brand', 'category'], ], ], ]);
Manage Settings
$client->setSettings('products', [ 'searchableAttributes' => ['name', 'brand', 'category'], 'attributesForFaceting' => ['brand', 'category', 'price'], ]); $settings = $client->getSettings('products');
Synonyms
$client->saveSynonym('products', 'syn1', [ 'objectID' => 'syn1', 'type' => 'synonym', 'synonyms' => ['phone', 'mobile', 'cell'], ], true);
Rules
$client->saveRule('products', 'rule1', [ 'objectID' => 'rule1', 'condition' => ['pattern' => 'budget', 'anchoring' => 'contains'], 'consequence' => ['params' => ['filters' => 'price < 500']], ], true);
Environment Variables
The SDK checks for credentials in this order:
- Constructor parameters
FLAPJACK_APP_ID/FLAPJACK_API_KEYALGOLIA_APP_ID/ALGOLIA_API_KEY(backward compatibility)
Requirements
- PHP >= 8.1 (except 8.3.0)
- ext-curl
- ext-json
- ext-mbstring
Migration from Algolia
See MIGRATION.md for a step-by-step guide to migrate from the Algolia PHP SDK.
Contributing
This repository hosts the generated Flapjack API client for PHP. To contribute, head over to the SDK Automation repository.
License
MIT - see LICENSE for details.