PHPackages                             hlquery/php-client - 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. [Search &amp; Filtering](/categories/search)
4. /
5. hlquery/php-client

ActiveLibrary[Search &amp; Filtering](/categories/search)

hlquery/php-client
==================

PHP client library for hlquery search engine

1.0.x-dev(1mo ago)20[4 issues](https://github.com/hlquery/php-api/issues)BSD-3-ClausePHPPHP &gt;=7.0CI passing

Since Apr 22Pushed 1w agoCompare

[ Source](https://github.com/hlquery/php-api)[ Packagist](https://packagist.org/packages/hlquery/php-client)[ RSS](/packages/hlquery-php-client/feed)WikiDiscussions unstable Synced 1w ago

READMEChangelogDependenciesVersions (2)Used By (0)

 [![hlquery logo](https://camo.githubusercontent.com/73df31369b4ebc9930146e062c6cd181663b23eb52c6f13b11214bd7b308bb57/68747470733a2f2f646f63732e686c71756572792e636f6d2f696d672f686c71756572792f322e706e67)](https://camo.githubusercontent.com/73df31369b4ebc9930146e062c6cd181663b23eb52c6f13b11214bd7b308bb57/68747470733a2f2f646f63732e686c71756572792e636f6d2f696d672f686c71756572792f322e706e67)

**A modular PHP client library for hlquery, designed with a familiar and intuitive API structure.**

[![Follow hlquery](https://camo.githubusercontent.com/75cdccbc8f754d8aaec11e587216294b7b76e26986cb5078e69f44f26d89ffe1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f466f6c6c6f772d253430686c71756572792d626c75653f6c6f676f3d78266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://x.com/hlquery)[![PHP build](https://camo.githubusercontent.com/1de442fc066e107464e4cebed3e13911b014aaa1acb3cdec2bab2703b27d3c05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502532306275696c642d70617373696e672d627269676874677265656e3f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://github.com/hlquery/php-api/actions/workflows/ci.yml)[![php-api](https://camo.githubusercontent.com/31a9dca793264fa325d56bdf53b25f3d0b4f3d0ddcaea045881b654d7faa7bae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d7068702d2d6170692d707572706c653f6c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://github.com/hlquery/php-api/)[![hlquery](https://camo.githubusercontent.com/90300358fda5ada7a5b8b284c07fc97c476adb0fe14cd96fd817722c5fe48e23/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769744875622d686c71756572792d626c75653f6c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://github.com/hlquery/hlquery/)[![License](https://camo.githubusercontent.com/c121fb04b6c6b23f6bbb4089ae74a648e4f8a5e512179a816018cc8401ed4203/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d425344253230332d2d436c617573652d6133356130663f6c6f676f3d6f70656e2d736f757263652d696e6974696174697665266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d303030303030)](https://opensource.org/licenses/BSD-3-Clause)

### What is the hlquery PHP API?

[](#what-is-the-hlquery-php-api)

The hlquery PHP API is the official PHP client for [hlquery](https://github.com/hlquery/hlquery). It gives PHP applications a straightforward way to talk to the search engine through a small client instead of manually assembling `curl` calls and JSON payloads.

The library wraps hlquery's HTTP endpoints in a service-based API so you can create collections, index documents, run searches, manage lexical resources, query SAM, and call custom module routes from normal PHP code.

### Why use it?

[](#why-use-it)

Use the PHP API when you want hlquery integration to feel like part of your application instead of a pile of hand-written REST calls. It reduces boilerplate, keeps authentication and request formatting consistent, and makes common operations easier to read and maintain.

### Install

[](#install)

Requirements:

- PHP `>= 7.0`
- `ext-curl`
- `ext-json`

Composer:

```
$ composer require hlquery/php-client
```

Local usage:

```
require_once __DIR__ . '/lib/autoload.php';

use Hlquery\Client;
$client = new Client(getenv('HLQ_BASE_URL') ?: (getenv('HLQUERY_BASE_URL') ?: 'http://localhost:9200'));
```

Composer usage:

```
require_once __DIR__ . '/vendor/autoload.php';

use Hlquery\Client;

$client = new Client('http://localhost:9200');
```

### Auth

[](#auth)

```
$client = new Client('http://localhost:9200', [
    'token' => 'your_token_here',
    'auth_method' => 'bearer',
]);

$client->setAuthToken('your_token_here', 'bearer');
$client->setAuthToken('your_api_key_here', 'api-key');
```

### Quick Start

[](#quick-start)

```
require_once __DIR__ . '/vendor/autoload.php';

use Hlquery\Client;

$client = new Client('http://localhost:9200');

$health = $client->health();
if ($health->isSuccess()) {
    echo "status: " . (($health->getBody()['status'] ?? 'ok')) . PHP_EOL;
}

$collections = $client->listCollections(0, 10);
print_r($collections->getBody());
```

### Collections

[](#collections)

List collections with pagination and iterate over the result:

```
$response = $client->listCollections(0, 100);

if (!$response->isSuccess()) {
    throw new RuntimeException('Failed to list collections: ' . $response->getStatusCode());
}

$body = $response->getBody();
$collections = $body['collections'] ?? [];

foreach ($collections as $collection) {
    $name = is_array($collection) ? ($collection['name'] ?? '') : $collection;

    if ($name === '') {
        continue;
    }

    echo $name . PHP_EOL;
}
```

### SAM

[](#sam)

The PHP client exposes all current SAM endpoints through `Client::sam()`:

- `search($collectionName, $query, $params = [])` calls `GET /sam/search`.
- `status($collectionName = null, $params = [])` calls `GET /sam/status`.
- `history($collectionName = null, $limit = 100, $params = [])` calls `GET /sam/history`.

You can also use the convenience property accessor `$client->sam` (same object as `$client->sam()`):

```
$status = $client->sam->status('music');
```

Use the SAM service for search, background status, and recent query history:

SAM is separate from vector search. It performs term and intent-style lookup, not vector similarity search.

```
$sam = $client->sam();

$status = $sam->status('music');
$history = $sam->history('music', 5);
$results = $sam->search('music', 'queen of pop', [
    'limit' => 10,
]);

print_r($status->getBody());
print_r($history->getBody());
print_r($results->getBody());
```

### SQL

[](#sql)

```
$sql = $client->sql();

$rows = $sql->raw('SHOW COLLECTIONS;');
$books = $sql->query(
    'books',
    'SELECT id, title FROM books ORDER BY title ASC LIMIT 3;'
);

print_r($rows->getBody());
print_r($books->getBody());
```

### Reduce Text Example

[](#reduce-text-example)

Use `executeRequest()` to call custom module routes directly:

```
$moduleResponse = $client->executeRequest('GET', '/modules//', null, [
    'q' => 'example query',
]);

print_r($moduleResponse->getBody());
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance75

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/20f8dc9168845ddb160ec248c757e6adc090fa35c15c40519b8e36dc1c79935d?d=identicon)[cferrys](/maintainers/cferrys)

---

Top Contributors

[![cferrys](https://avatars.githubusercontent.com/u/79171176?v=4)](https://github.com/cferrys "cferrys (38 commits)")

---

Tags

hlqueryphprest-api

### Embed Badge

![Health badge](/badges/hlquery-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/hlquery-php-client/health.svg)](https://phpackages.com/packages/hlquery-php-client)
```

###  Alternatives

[shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

186.7M12](/packages/shyim-opensearch-php-dsl)[awesome-nova/dependent-filter

Dependent filters for Laravel Nova

26190.2k](/packages/awesome-nova-dependent-filter)

PHPackages © 2026

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