Closed
Description
Hi,
I'm not sure if this is the right place to report this issue. If it's not, please feel free to close this issue and let me know where I should post it.
In the code snippet provided in the "Get Started" section to start using Algolia, there are some errors:
<?php
require(__DIR__."/vendor/autoload.php");
use Algolia\AlgoliaSearch\SearchClient;
$url = "https://dashboard.algolia.com/sample_datasets/movie.json";
$response = file_get_contents($url);
$records = json_decode($response, true);
$client = SearchClient::create("ID4NV3D7MX", "xxx");
$index = $client->initIndex("your_index_name");
$index->saveObjects($records, [ 'autoGenerateObjectIDIfNotExist' => true ]);
use Algolia\AlgoliaSearch\SearchClient
will throw an error because SearchClient doesn't exist in that namespace. From v4 onwards, the correct namespace is Algolia\AlgoliaSearch\Api\SearchClient
.
Furthermore, initIndex
is no longer available in the new class, so it must be removed.
Maybe is better to show the Get Started example available in the PHP docs.
Have a nice day
Metadata
Metadata
Assignees
Labels
No labels