Skip to content

Commit f557257

Browse files
damcoushortcuts
andauthored
docs: add PHP getting started guide (#442)
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent d2517cc commit f557257

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

website/docs/api-clients/installation.mdx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import TabItem from '@theme/TabItem';
99
groupId="language"
1010
defaultValue="js"
1111
values={[
12-
{ label: 'JavaScript', value: 'js', }
12+
{ label: 'JavaScript', value: 'js', },
13+
{ label: 'PHP', value: 'php', }
1314
]
1415
}>
1516
<TabItem value="js">
@@ -111,5 +112,41 @@ const res = await personalizationClient.getUserTokenProfile({
111112
console.log('[Results]', res);
112113
```
113114

115+
</TabItem>
116+
117+
<TabItem value="php">
118+
119+
## Installation
120+
121+
First, install Algolia PHP API Client via the composer package manager:
122+
```bash
123+
composer require algolia/algoliasearch-client-php
124+
```
125+
## Using the client
126+
127+
Then, create objects on your index:
128+
```php
129+
$client = Algolia\AlgoliaSearch\Api\SearchClient::create(
130+
'<YOUR_APP_ID>',
131+
'<YOUR_API_KEY>'
132+
);
133+
134+
$client->saveObject('<YOUR_INDEX>', ['objectID' => 1, 'name' => 'Foo']);
135+
```
136+
137+
Finally, you may begin searching an object using the `search` method:
138+
```php
139+
$objects = $client->search('<YOUR_INDEX>', ['query' => 'Foo']);
140+
```
141+
142+
Another example with the personalization client:
143+
```php
144+
$client = Algolia\AlgoliaSearch\Api\PersonalizationClient::create(
145+
'<YOUR_APP_ID>',
146+
'<YOUR_API_KEY>'
147+
);
148+
149+
$res = $client->getUserTokenProfile('<YOUR_TOKEN>');
150+
```
114151
</TabItem>
115152
</Tabs>

0 commit comments

Comments
 (0)