Skip to content

Commit

Permalink
docs: add PHP getting started guide (#442)
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
damcou and shortcuts authored Apr 29, 2022
1 parent d2517cc commit f557257
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion website/docs/api-clients/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import TabItem from '@theme/TabItem';
groupId="language"
defaultValue="js"
values={[
{ label: 'JavaScript', value: 'js', }
{ label: 'JavaScript', value: 'js', },
{ label: 'PHP', value: 'php', }
]
}>
<TabItem value="js">
Expand Down Expand Up @@ -111,5 +112,41 @@ const res = await personalizationClient.getUserTokenProfile({
console.log('[Results]', res);
```

</TabItem>

<TabItem value="php">

## Installation

First, install Algolia PHP API Client via the composer package manager:
```bash
composer require algolia/algoliasearch-client-php
```
## Using the client

Then, create objects on your index:
```php
$client = Algolia\AlgoliaSearch\Api\SearchClient::create(
'<YOUR_APP_ID>',
'<YOUR_API_KEY>'
);

$client->saveObject('<YOUR_INDEX>', ['objectID' => 1, 'name' => 'Foo']);
```

Finally, you may begin searching an object using the `search` method:
```php
$objects = $client->search('<YOUR_INDEX>', ['query' => 'Foo']);
```

Another example with the personalization client:
```php
$client = Algolia\AlgoliaSearch\Api\PersonalizationClient::create(
'<YOUR_APP_ID>',
'<YOUR_API_KEY>'
);

$res = $client->getUserTokenProfile('<YOUR_TOKEN>');
```
</TabItem>
</Tabs>

0 comments on commit f557257

Please sign in to comment.