Skip to main content
To access the API directly, you may need to interact with Algolia’s PHP client. The Algolia PHP client lets you use Algolia’s features in the most customizable way possible.
Before you access the Algolia’s PHP client directly, make sure that there aren’t any breaking changes:
composer require algolia/algoliasearch-client-php

Algolia::client

The client method returns an instance of Algolia\AlgoliaSearch\SearchClient:
PHP
use Algolia\ScoutExtended\Facades\Algolia;

$client = Algolia::client();

$apiKeys = $client->listApiKeys();
$indices = $client->listIndices();
$client->copyIndex('indexNameSrc', 'indexNameDest');
$client->moveIndex('indexNameSrc', 'indexNameDest');
// ...

Algolia::index

The index method returns an instance of Algolia\AlgoliaSearch\SearchIndex:
PHP
use Algolia\ScoutExtended\Facades\Algolia;

$index = Algolia::index(App\Article::class);

$synonym = $index->getSynonym('a-unique-identifier');
$rule = $index->getRule('a-unique-identifier');
$index->delete();
// ...

Algolia::analytics

The analytics method returns an instance of Algolia\AlgoliaSearch\AnalyticsClient:
PHP
use Algolia\ScoutExtended\Facades\Algolia;

$analytics = Algolia::analytics();
$test = $analytics->getABTest('a-unique-identifier');
// ...
I