Oct 21, 2024
Upgrade the PHP API clients to v4
The latest major version of the algoliasearch-client-php
package is v4.
This page lists the breaking changes since the last release, v3.
Method changes overview
The following table has links for all methods and their replacements
Search API client
Recommend API client
Client imports
The imports for the API clients changed.
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
// Search API
Algolia\AlgoliaSearch\Api\SearchClient
// Recommend API
Algolia\AlgoliaSearch\Api\RecommendClient
// A/B testing
Algolia\AlgoliaSearch\Api\AbtestingClient
// Analytics API
Algolia\AlgoliaSearch\Api\AnalyticsClient
// Ingestion API
Algolia\AlgoliaSearch\Api\IngestionClient
// Insights API
Algolia\AlgoliaSearch\Api\InsightsClient
// Monitoring API
Algolia\AlgoliaSearch\Api\MonitoringClient
// Personalization API
Algolia\AlgoliaSearch\Api\PersonalizationClient
// Query Suggestions API
Algolia\AlgoliaSearch\Api\QuerySuggestionsClient
// Usage API
Algolia\AlgoliaSearch\Api\UsageClient
Other imports
Copy
1
2
3
4
5
<?php
// Configuration
Algolia\AlgoliaSearch\Configuration
// User agent
Algolia\AlgoliaSearch\Support\AlgoliaAgent
Removal of initIndex
All methods are methods of a client
instance.
The initIndex
method of the SearchClient
has been removed.
Instead, all methods require a indexName
parameter.
Copy
1
2
3
4
5
6
7
8
9
<?php
// v3
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
$index = $client->initIndex('ALGOLIA_INDEX_NAME');
$index->search('QUERY');
// v4
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
$index = $client->searchSingleIndex('ALGOLIA_INDEX_NAME', ['query' => 'QUERY'])
Wait for tasks
The wait
method has been removed.
Instead, use one of the following helpers:
waitForTask
to wait until indexing operations are donewaitForAppTask
to wait for application-level taskswaitForApiKey
to wait for API key operations
Copy or move indices, settings, synonyms, or rules
Use the operationIndex
method,
which replaces the following methods:
copyIndex
moveIndex
copyRules
copySynonyms
copySettings
Did you find this page helpful?