packagist meilisearch/meilisearch-php v2.0.0-beta.1
v2.0.0-beta.1 🌱

6 hours ago

Warning

This is a beta release.

While we recommend against production usage due to breaking changes, the code is stable. Please consider whether you can afford the potential upcoming breaking changes before upgrading.

Migration guide

Refactor tasks as objects, and task status and type as enums

This introduces two changes:

  • Asynchronous operations now return Tasks as an object instead of an array
  • Tasks can be awaited with the new wait(int $timeoutInMs = 5000, int $intervalInMs = 50): Task method

Awaiting tasks:

// Before
$promise = $this->client->createIndex('new-index', ['primaryKey' => 'objectID']);
$this->index->waitForTask($promise['taskUid']);

// After
$this->client->createIndex('new-index', ['primaryKey' => 'objectID'])->wait();

Asserting task status:

// Before
$task = $this->client->getTask($taskUid);
if ($task['status'] === 'succeeded') {
    // do something
}

// After
if ($task->getStatus() === TaskStatus::Succeeded) {
    // do something
}

Asserting task types:

// Before
$task = $this->client->getTask($taskUid);
if ($task['type'] === 'indexCreation') {
    // do something
}

// After
$task = $this->client->getTask($taskUid);
if ($task->getType() === TaskType::IndexCreation) {
    // do something
}

Remove custom exception for JSON parsing

Before: catching SDK-specific JSON exceptions

<?php

try {
    $client->index('books')->addDocuments([["title" => "\xB1\x31"]]);
} catch (JsonEncodingException | JsonDecodingException $e) {
    // handle JSON errors
}

After: catching native PHP JsonException

<?php

try {
    $client->index('books')->addDocuments([["title" => "\xB1\x31"]]);
} catch (\JsonException $e) {
    // handle JSON errors
}

⚠️ Breaking changes

🚀 Enhancements

🐛 Bug Fixes

  • Cast federation payload explicitly to an object (#757) @norkunas

⚙️ Maintenance/misc

Thanks to @Strift, @bpolaszek, and @norkunas! 🎉

See full changelog: v1.16.0...v2.0.0-beta.1

Don't miss a new meilisearch-php release

NewReleases is sending notifications on new releases.