PHPackages                             shevabam/meilisearch-light-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. [HTTP &amp; Networking](/categories/http)
4. /
5. shevabam/meilisearch-light-php-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

shevabam/meilisearch-light-php-client
=====================================

Meilisearch Light PHP Client

1.0.4(3y ago)280PHPPHP &gt;=5.6.0

Since Jun 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/shevabam/meilisearch-light-php-client)[ Packagist](https://packagist.org/packages/shevabam/meilisearch-light-php-client)[ Docs](https://github.com/shevabam/meilisearch-light-php-client)[ RSS](/packages/shevabam-meilisearch-light-php-client/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (5)DependenciesVersions (6)Used By (0)

Meilisearch Light PHP Client
============================

[](#meilisearch-light-php-client)

Meilisearch Light PHP Client is a PHP library for using a Meilisearch server in PHP.

PHP 5.6+ compatible unlike official clients ([meilisearch-php](https://github.com/meilisearch/meilisearch-php) and [meilisearch-symfony](https://github.com/meilisearch/meilisearch-symfony)) that allow PHP 7.4 or 8.0.

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

[](#requirements)

- Meilisearch server URL
- Search API Key
- Admin API Key

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

[](#installation)

With Composer, run this command:

```
composer require shevabam/meilisearch-light-php-client

```

Usage
-----

[](#usage)

### Request

[](#request)

First, include the library in your code using the Composer autoloader:

```
require 'vendor/autoload.php';
```

Then, create an MeilisearchLightClient object with some paremeters:

```
$host = 'http://xxx.xxx.xxx.xxx:7700';
$searchKey = 'yyy';
$adminKey = 'zzz';

$Request = new MeilisearchLighClient\Request($host);
```

Make a call:

```
$params = ['key' => $adminKey];
$Request->call($params, 'GET', 'indexes');
```

The `call` method takes as a parameter:

- the parameters (see below)
- the HTTP method (GET, POST, PUT, ...)
- the endpoint (corresponds to the Meilisearch query)
- the data to transmit: can be a file (must start with @) or an array

The parameters allow you to specify the API key to use (search or admin) as well as the headers if necessary:

```
$params = [
    'key' => $searchKey,
    'headers' => ['Content-type: application/json'],
];
```

### Response

[](#response)

To check that a request is valid, use the `isOk()` method:

```
if ($Request->isOk())
{
    $Response = $Request->getResponse();

    var_dump($Response->get()); // Response content
}
else
{
    echo $Request->getHttpStatus();
}
```

By default, the return is an object. To get an array:

```
$Response = $Request->getResponse(true);
```

### Examples

[](#examples)

#### List of indexes:

[](#list-of-indexes)

```
