Migration guide
⚠️ Breaking changes
Requirements:
- PHP: now requires PHP 8.1
- Symfony: now requires Symfony 6.4+ or 7.x
SearchService deprecation
SearchService is now deprecated, and we recommend migrating to the new SearchManagerInterface instead.
Before (v0.15.10)
use Meilisearch\Bundle\SearchService;
use Doctrine\Persistence\ObjectManager;
final class PostSearch
{
public function __construct(
private SearchService $searchService,
private ObjectManager $om,
) {}
public function index(Post $post): void
{
// array<array<string, array{taskUid: int, status: string, ...}>>
$response = $this->searchService->index($this->om, $post);
$taskUid = $response[0]['posts']['taskUid'];
}
public function search(string $query): array
{
// list<Post>
return $this->searchService->search(
$this->om,
Post::class,
$query,
['limit' => 20],
);
}
}
After (v0.16.0)
use Meilisearch\Bundle\SearchManagerInterface;
use Meilisearch\Bundle\Model\SearchResults;
use Meilisearch\Contracts\Task;
final class PostSearch
{
public function __construct(
private SearchManagerInterface $searchManager,
) {}
public function index(Post $post): void
{
// list<array<non-empty-string, Task>>
$batches = $this->searchManager->index($post);
/** @var Task $task */
$task = $batches[0]['posts'];
$taskUid = $task->getTaskUid();
$task->wait(); // optional
}
public function search(string $query): SearchResults
{
// SearchResults<Post>
$results = $this->searchManager->search(
Post::class,
$query,
['limit' => 20],
);
// Entities:
$posts = $results->getHits(); // array<Post>
// Metadata (optional):
$totalHits = $results->getTotalHits();
return $results;
}
}
🚀 Enhancements
Note
This release is compatible with meilisearch-php@v2.0.0-beta.5, which brings type improvements.
- Add Data providers extension point (#410) @norkunas
- Add support for Symfony 8 (#419) @unicolored
- Wrap search response in SearchResults object with array access/iterator (#430) @norkunas
- Add support for
meilisearch-php@v2(#432) @norkunas
⚙️ Maintenance/misc
- feat: use composer's
--no-security-blockingflag (#409) @Chris53897 - Fix CS (#414) @norkunas
- Bump actions/checkout from 5 to 6 (#411) @dependabot[bot]
- Fix PHP-CS-Fixer deprecation (#415) @norkunas
- Remove bors and use GitHub merge queue (#416) @curquiza
- Remove
bors.tomlconfiguration file (#417) - Use Meilisearch Enterprise Edition (#418) @Strift
- Drop doctrine annotations (#424) @norkunas
- Add AI usage disclosure guidelines to CONTRIBUTING.md (#431)
Thanks again to @Chris53897, @Chris8934, @Strift, @brunoocasali, @curquiza, @dependabot[bot], @norkunas, @unicolored and dependabot[bot]! 🎉