meilisearch/meilisearch-php
Official Meilisearch PHP SDK: a fast, easy API client to index documents, manage settings, and run searches with Meilisearch or Meilisearch Cloud. Supports popular HTTP clients and customizable transport.
Start by installing the package via Composer with a PSR-18 HTTP client (e.g., Guzzle):
composer require meilisearch/meilisearch-php guzzlehttp/guzzle http-interop/http-factory-guzzle:^1.0
Ensure Meilisearch is running (locally or via Meilisearch Cloud). Instantiate the client with your instance URL and API key, then create or access an index:
$client = new Client('http://127.0.0.1:7700', 'masterKey');
$index = $client->index('movies');
First use case: Add documents and perform a typo-tolerant search — no prior schema setup required.
$client->createIndex() or access existing indexes via $client->index($uid). Index settings (e.g., filterableAttributes, searchableAttributes) should be configured once via async tasks, then tracked using the returned uid.addDocuments(), updateDocuments(), deleteDocuments(). Always capture the uid from async operations to poll task status via $index->getTask($uid).search($query, $options) with filters, pagination, highlighting, and facets. Leverage PHP arrays for complex filters (e.g., ['category = books AND price < 50']).status === 'succeeded').Client constructor for timeouts, retries, or middleware (e.g., logging):
new Client($url, $key, new GuzzleHttpClient(['timeout' => 5.0]));
$e->getMessage() (not $e->message) and check for specific subclasses like Meilisearch\Exceptions\ApiException.nyholm/psr7). Missing factories cause "HTTP Factory not found" errors at runtime.getTasks()) now return typed objects (TaskResults). Update legacy code to use ->getResults() instead of array access.Client::create() with a temporary Meilisearch instance for unit tests; the client’s raw() method helps inspect raw API responses.addDocumentsInBatches() or deleteDocumentsBy() over bulk operations to avoid timeouts.How can I help you explore Laravel packages today?