AlgoliaSearch\Client::__construct PHP Method

__construct() public method

Algolia Search initialization.
public __construct ( string $applicationID, string $apiKey, array | null $hostsArray = null, array $options = [] )
$applicationID string the application ID you have in your admin interface
$apiKey string a valid API key for the service
$hostsArray array | null the list of hosts that you have received for the service
$options array
    public function __construct($applicationID, $apiKey, $hostsArray = null, $options = array())
    {
        if (!function_exists('curl_init')) {
            throw new \Exception('AlgoliaSearch requires the CURL PHP extension.');
        }
        if (!function_exists('json_decode')) {
            throw new \Exception('AlgoliaSearch requires the JSON PHP extension.');
        }
        $this->caInfoPath = __DIR__ . '/../../resources/ca-bundle.crt';
        foreach ($options as $option => $value) {
            switch ($option) {
                case self::CAINFO:
                    $this->caInfoPath = $value;
                    break;
                case self::CURLOPT:
                    $this->curlOptions = $this->checkCurlOptions($value);
                    break;
                case self::PLACES_ENABLED:
                    $this->placesEnabled = (bool) $value;
                    break;
                default:
                    throw new \Exception('Unknown option: ' . $option);
            }
        }
        $this->context = new ClientContext($applicationID, $apiKey, $hostsArray, $this->placesEnabled);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function __construct($applicationID, $apiKey, $hostsArray = null, $options = array())
 {
     parent::__construct($applicationID, $apiKey, $hostsArray, $options);
 }
All Usage Examples Of AlgoliaSearch\Client::__construct