# algoliasearch-client-php: a generated low-level client for the Algolia API

> The Algolia PHP client is a thin, generated HTTP client for the Algolia search API, published on Packagist under the MIT licence and requiring PHP 8.0 or newer. It gives you direct access to indexing and search calls without a framework abstraction, and it is maintained by code generation rather than by hand.

**algolia/algoliasearch-client-php** — ⚡️ A fully-featured and blazing-fast PHP API client to interact with Algolia.

- Repository: https://github.com/algolia/algoliasearch-client-php
- Website: https://www.algolia.com/doc/libraries/sdk/install#php
- Stars: 696 · Forks: 112
- Language: PHP
- License: MIT
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/algolia-algoliasearch-client-php

## A generated client, not a hand-written wrapper

The most important thing to know about the Algolia PHP client is where the code comes from. The README states that this repository hosts the code of the generated Algolia API client for PHP, and directs contributors to the api-clients-automation repository, with contributing guides on a separate documentation site. The same pattern applies across Algolia's client libraries, and it is visible in this repository's own tooling: a php-cs-fixer configuration for style, phpstan.neon for static analysis, phpunit.xml.dist for the test runner, a CHANGELOG.md, an AGENTS.md and a committed composer.lock.

That provenance has two consequences for an adopting team. The first is coverage: a generated client tracks the API surface rather than the needs of one application, so endpoints and parameters you have not thought of are already there and already typed. The second is that the code in this repository is not where feature decisions are made. If you need a method that does not exist, the request goes to the automation repository and to whatever spec drives the generator, not to a hand patch here.

The features list in the README is short by design: a thin and minimal low-level HTTP client to interact with the Algolia API, supporting PHP 8.0 or newer. The word thin is the one to take seriously. This package is the transport layer, and anything you build on top of it is your code.

## Composer install and a first client instance

Installation is a single Composer command, pinning the major version:

```bash
composer require algolia/algoliasearch-client-php "^4.0"
```

The constraint of PHP 8.0 or newer is the other installation fact worth noting, and it is stricter than many projects still running in production. A codebase stuck on PHP 7.4 cannot use this client without an upgrade, and because the package is generated against a current API description, the version floor is not going to be relaxed.

The client is created through a static factory in the SearchClient class, taking your application ID and API key:

```php
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);
```

Two placeholders matter. The application ID identifies your Algolia application and the API key authenticates it. The key passed to create is a full credential, so the decision about which key ends up in a browser is yours to make before the code ships. The index name is the third placeholder, repeated in every call rather than fixed on the client, which is what lets one client instance talk to several indices.

The response of a write is an array, and the useful part of it is the task ID, because indexing is asynchronous.

## waitForTask is what makes writes observable

The README example does something that a first-time user would not guess, and it does it immediately after the save: it polls the task status so you know when the record has been indexed.

```php
// Poll the task status to know when it has been indexed
$client->waitForTask('<YOUR_INDEX_NAME>', $response['taskID']);
```

The task ID comes out of the write response, and waitForTask blocks until that specific operation has completed. This is the difference between Algolia's model and a database's: a write is accepted and queued, and the read path is not immediately consistent with it. Without the wait, a search issued straight after a save can legitimately return no results, which in application code looks like a bug in your index settings rather than a timing artefact.

The consequence for design is that write paths need a decision. Blocking on waitForTask makes the operation synchronous from your caller's point of view, at the cost of holding a request open. Not blocking keeps the request fast and pushes the guarantee onto your own bookkeeping, which is the shape that suits a batch import script better than a web request that a user is waiting on. The client supports both; it just does not choose for you.

## Search takes a requests array, which is how batching works

The search call in the README takes a single argument that wraps an array of requests, and each request carries its own index name, query and pagination:

```php
// 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);
```

The array-of-requests shape is not decoration. It is the form that lets a single round trip carry several queries, and in many cases several different indices, since each request names its own indexName. A multi-facet or multi-index interface is a natural fit for this, and a user interface that fires one request per widget is the case the shape is designed to avoid.

Note also that the returned value is a raw structure you dump rather than a hydrated model. The client gives you the response array and leaves rendering, highlighting and result shaping to you. That is the payoff of the thin design, and it is also the work you take on. The response for a multi-request call carries one result set per request, and mapping those back onto your own UI state is your code, not the library's.

The comment on the example calls out typo tolerance as a property of the search itself, which is a service feature rather than something the client switches on.

## Framework integrations are separate projects, and that is the point

The README's link row points to a Laravel integration and a Symfony bundle, and neither is this repository. The PHP client is framework-agnostic, and the framework packages sit on top of it.

That separation is a decision about maintenance ownership, and it lines up with the generated-code story. A framework integration can change its own conventions, its own service provider, its own configuration format and its own test helpers without touching the API client, and the client can regenerate itself from the API description without breaking anyone's dependency on their framework's idioms. If both lived in one package, every generator change would ripple into framework code.

The practical advice follows from that. If your application is a Laravel or Symfony project, look at the corresponding integration rather than wiring the low-level client into your framework by hand, because you will otherwise rebuild the parts that integration already handles. If you are on anything else, or you want the raw call shape for a specific reason, the low-level client is the correct dependency.

The README also points to a community forum and a Stack Overflow tag for questions, and a bug report link that goes to the api-clients-automation issue tracker rather than to this repository, which is a small detail that tells you where a real bug lands.

## Release cadence and what a major version upgrade costs

The release history shows a steady cadence with numbered minor bumps: 4.50.0 on 2026-10-12, 4.49.0 on 2026-09-09 and 4.47.0 on 2026-08-18. The gap between 4.49.0 and 4.50.0 is about a month, and the numbering in the 4.4x range suggests frequent increments over a stable 4.x major line.

The last push was on 2026-10-12, the same day as the 4.50.0 release, and the project is not archived. The MIT licence is the permissive one, and the LICENSE file at the repository root is the authoritative copy.

What a major version bump means for a generated client is worth spelling out. The install command pins the major version, so an upgrade inside 4.x is a normal Composer update with the API surface you already use. Moving to a new major is where method signatures, parameter shapes or the class namespace could change, and because the code is generated rather than hand-curated, the diff between major versions can be larger than the version number suggests. The pragmatic approach is to read the CHANGELOG.md in the repository before bumping a major, since that file is the one place the generated changes are summarized.

The dependency declaration in the package is PHP 8.0 or newer, which means the floor to check is your runtime, not the client.

## Conclusion

Adopt algoliasearch-client-php when you want direct control over indexing and query calls, need the raw response shape to build your own rendering or ranking logic, and prefer a client with no framework lock-in. Do not adopt it if you want a batteries-included search UI, because this is deliberately a thin low-level HTTP client and the Laravel and Symfony links in the README point at separate integrations for that. Before you commit, decide which key you use and keep the admin key on the server while shipping only a search-only key to the browser, confirm your PHP runtime is on version 8.0 or newer since the package declares that constraint, and plan for the waitForTask call after every write, because indexing is asynchronous and a search issued too early will miss the record.

## FAQ

### How do I install the Algolia PHP API client?

Install it with Composer using composer require algolia/algoliasearch-client-php "^4.0". The package requires PHP 8.0 or newer, and it is published on Packagist under the MIT licence.

### How do I create a client and index a record with the PHP client?

Call SearchClient::create with your application ID and API key, then call saveObject with the index name and the record, which includes an objectID. The write response carries a taskID that you pass to waitForTask so you know when the record has been indexed.

### What is the difference between the low-level PHP client and the Laravel or Symfony integrations?

The README describes this package as a thin and minimal low-level HTTP client, and links to separate Laravel and Symfony integrations. The framework packages build on the client rather than replacing it, so a Laravel or Symfony project would normally use the integration instead of wiring the low-level client in by hand.

### Is the Algolia PHP client maintained by hand?

No. The README states that this repository hosts the code of the generated Algolia API client for PHP, and points contributors to the api-clients-automation repository for the code that produces it. Changes to the API surface are therefore made upstream and generated here.

### Which PHP versions does the Algolia PHP client support?

The features list states that the client supports PHP 8.0 or newer. Recent releases include 4.50.0 from 2026-10-12, 4.49.0 from 2026-09-09 and 4.47.0 from 2026-08-18, and the last push to the repository was on 2026-10-12.

## Sources

- [algolia/algoliasearch-client-php on GitHub](https://github.com/algolia/algoliasearch-client-php)
- [License: MIT](https://github.com/algolia/algoliasearch-client-php/blob/main/LICENSE)
- [Project website](https://www.algolia.com/doc/libraries/sdk/install#php)
- [README](https://github.com/algolia/algoliasearch-client-php/blob/main/README.md)
- [Releases](https://github.com/algolia/algoliasearch-client-php/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/algolia-algoliasearch-client-php
