Skip to content

docs: add PHP getting started guide #442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>