Skip to content

Commit 7d518b2

Browse files
authored
docs(php): update migration guide for PHP (#935)
1 parent f1522a3 commit 7d518b2

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

website/docs/clients/guides/send-data-to-algolia.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ $records = [
103103
$requests = [];
104104

105105
foreach ($records as $record) {
106-
$requests += [
106+
$requests[] = [
107107
'action' => 'addObject',
108108
'body' => $record
109109
];

website/docs/clients/migration-guides/php.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ title: PHP
66
|-----------------------------------------------|:---------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
77
| `"algolia/algoliasearch-client-php": "^3.2"` | `"algolia/algoliasearch-client-php": "^4.0@alpha"` | **During the beta phase**, the clients are available under the package 4.x.x-alpha , you can find a full list [here](https://packagist.org/packages/algolia/algoliasearch-client-php). |
88
| `Algolia\AlgoliaSearch` | `Algolia\AlgoliaSearch\Api` | Exported clients have now the namespace suffixed by `Api`. |
9+
| `Algolia\AlgoliaSearch\Support\UserAgent` | `Algolia\AlgoliaSearch\Support\AlgoliaAgent` | `UserAgent` class has been renamed to `AlgoliaAgent` for consistency across client languages (`addCustomUserAgent` method also became `addAlgoliaAgent`). |
10+
| `Algolia\AlgoliaSearch\SearchIndex` | **removed** | Since the method `initIndex` doesn't exist anymore, we decided to merge the `SearchIndex` class inside the `SearchClient` one, now all the methods related to search endpoints are located there. |
911
| `Algolia\AlgoliaSearch\Cache\FileCacheDriver` | **removed** | This implementation of the `CacheInterface` is not available anymore in the Client. If you feel the need for it, [please open an issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&template=Feature_request.md) |
1012

11-
1213
### Usage
1314

1415
To get started, first uninstall the previously added clients.
@@ -55,3 +56,23 @@ $searchResults2 = $client->search([
5556
],
5657
]);
5758
```
59+
60+
### Generate a secured Api Key
61+
62+
The `SearchClient::generateSecuredApiKey()` from the previous client was removed, but you can still create them:
63+
64+
```php
65+
use Algolia\AlgoliaSearch\Support\Helpers;
66+
67+
// Key will be valid for 25 hours.
68+
$validUntil = time() + (3600 * 25);
69+
70+
$urlEncodedRestrictions = Helpers::buildQuery([
71+
'restrictIndices' => '<YOUR_INDEX_NAME>',
72+
'validUntil' => $validUntil,
73+
]);
74+
75+
$content = hash_hmac('sha256', $urlEncodedRestrictions, '<YOUR_SEARCH_KEY>').$urlEncodedRestrictions;
76+
$securedSearchKey = base64_encode($content);
77+
78+
```

0 commit comments

Comments
 (0)