algoliasearch-client-php is the official MIT-licensed PHP client for the Algolia search API, built for PHP 8 developers who want to add hosted search to an application without writing the HTTP layer themselves.
What it is
The project is a thin and minimal low-level HTTP client for Algolia's API, distributed through Composer as algolia/algoliasearch-client-php at version ^4.0. It requires PHP ^8.0 and exposes a single entry point through the Algolia\AlgoliaSearch\Api\SearchClient class, created with SearchClient::create(). The code is not hand-maintained in this repository: it is a generated client, and contributions, bug reports, and generation logic belong to the upstream api-clients-automation repository. The README frames the package as the starting point for integrating Algolia into a PHP project, with dedicated documentation paths for Laravel and Symfony.
The concrete problem it solves is the request layer between a PHP application and Algolia's REST API. Without it, a team writes and maintains its own HTTP calls, authentication handling, response deserialization, and task-status polling against Algolia endpoints. This client replaces that hand-rolled wrapper with named methods: saveObject() for index writes, waitForTask() to poll until an indexing task completes, and search() for queries. The README's example shows a record being saved, the response being inspected with var_dump, the indexing task awaited, and a batched search issued with an indexName, query, and hitsPerPage value of 50.
Key capabilities
SearchClient::create() provides the client instance used for every subsequent API call.
saveObject() writes a record into an Algolia index and returns a response containing a taskID.
waitForTask() polls indexing status using that taskID so callers know when a record becomes searchable.
search() accepts a batched requests array, each entry carrying indexName, query, and hitsPerPage.
- Search results are returned with typo tolerance applied by the API.
- Topic coverage includes faceted search, geo search, and search synonyms.
- Installation is a single Composer command against package version
^4.0, with PHP ^8.0 as the floor.
Who uses it and how
- PHP teams adding hosted search to an existing application, using
SearchClient::create() as the single access point to Algolia.
- Laravel projects, which have a documented integration path in the README's link set.
- Symfony projects, likewise covered by a linked framework-specific guide.
- Applications that need faceted or geo search, indicated by the repository topics alongside
search-synonyms.
- Teams indexing records and then waiting on
waitForTask() before rendering results, which is the workflow shown in the README example.
Getting started
Install with Composer: composer require algolia/algoliasearch-client-php "^4.0", then import Algolia\AlgoliaSearch\Api\SearchClient and construct the client. Full documentation is hosted at the Algolia SDK install page linked from the repository.
How it compares
No list of paid products this client replaces is provided in the facts, and no comparable PHP search client is named either. On the evidence available, it stands alone in this registry as the official Algolia PHP client.
When to use it — and when not to
A self-hoster must operate an Algolia account and application, since this package is a client for Algolia's hosted API rather than a search engine that can be run locally. Teams on PHP versions below 8.0 cannot use it, and anyone wanting to fix or extend the client's generated code must work through the upstream api-clients-automation repository instead of this one. The README is sparse — its code samples contain blank placeholders for credentials and index names — so realistic evaluation depends on the external documentation rather than the repository itself.
project readme (upstream, from github) — read inline
The perfect starting point to integrate Algolia within your PHP project
Documentation •
Laravel •
Symfony •
Community Forum •
Stack Overflow •
Report a bug •
Support
✨ Features
- Thin & minimal low-level HTTP client to interact with Algolia's API
- Supports php
^8.0.
💡 Getting Started
First, install Algolia PHP API Client via the composer package manager:
composer require algolia/algoliasearch-client-php "^4.0"
You can now import the Algolia API client in your project and play with it.
use Algolia\AlgoliaSearch\Api\SearchClient;
$client = SearchClient::create('<YOUR_APP_ID>', '<YOUR_API_KEY>');
// Add a new record to your Algolia index
$response = $client->saveObject(
'<YOUR_INDEX_NAME>',
['objectID' => 'id',
'test' => 'val',
],
);
// play with the response
var_dump($response);
// Poll the task status to know when it has been indexed
$client->waitForTask('<YOUR_INDEX_NAME>', $response['taskID']);
// Fetch search results, with typo tolerance
$response = $client->search(
['requests' => [
['indexName' => '<YOUR_INDEX_NAME>',
'query' => '<YOUR_QUERY>',
'hitsPerPage' => 50,
],
],
],
);
// play with the response
var_dump($response);
For full documentation, visit the Algolia PHP API Client.
❓ Troubleshooting
Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client. You can also open a GitHub issue
Contributing
This repository hosts the code of the generated Algolia API client for PHP, if you'd like to contribute, head over to the main repository. You can also find contributing guides on our documentation website.
📄 License
The Algolia PHP API Client is an open-sourced software licensed under the MIT license.