Integrations / Frameworks / Laravel / Access API Directly

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.

Please head over to Algolia’s PHP client documentation to find the available methods and features.

To access the Algolia’s PHP client directly, perform a composer require algolia/algoliasearch-client-php when there’s a new major release to make sure there are no breaking changes.

Algolia::client

The client method returns an instance of Algolia\AlgoliaSearch\SearchClient:

1
2
3
4
5
6
7
8
9
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:

1
2
3
4
5
6
7
8
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:

1
2
3
4
5
use Algolia\ScoutExtended\Facades\Algolia;

$analytics = Algolia::analytics();
$test = $analytics->getABTest('a-unique-identifier');
// ...
Did you find this page helpful?