PHPackages                             alsoasked/also-asked-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. alsoasked/also-asked-php

ActiveLibrary[API Development](/categories/api)

alsoasked/also-asked-php
========================

A PHP library for the AlsoAsked API

1.1.0(2y ago)1807↓50%MITPHPCI passing

Since Aug 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/AlsoAsked/also-asked-php)[ Packagist](https://packagist.org/packages/alsoasked/also-asked-php)[ Docs](https://alsoasked.com)[ RSS](/packages/alsoasked-also-asked-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (4)Used By (0)

AlsoAsked PHP Client
====================

[](#alsoasked-php-client)

[![AlsoAsked Logo](/assets/images/logo-blue.png)](/assets/images/logo-blue.png)

For more information, please visit .

Installation &amp; Usage
------------------------

[](#installation--usage)

### Requirements

[](#requirements)

PHP 7.4 and later.

### Composer

[](#composer)

To install the bindings via [Composer](https://getcomposer.org/), add the following to `composer.json`:

```
{
  "require": {
    "AlsoAsked/also-asked-php": "1.0.0"
  }
}
```

Then run `composer install`

Examples
--------

[](#examples)

### Create a client

[](#create-a-client)

You'll need to begin by creating a client for the API you wish to use, as well as specify the API key you wish to use.

We do this by first creating an HTTP client respecting the [PSR-18](https://www.php-fig.org/psr/psr-18/) standard.

The `\Http\Discovery\Psr18ClientDiscovery` class will automatically discover an PSR-18 HTTP client from the installed composer packages, meaning you'll need an HTTP client installed which implements PSR-18 if you don't already.

A common HTTP client which does is [Guzzle](https://docs.guzzlephp.org/en/stable/), we can install this by running `composer require guzzlehttp/guzzle:^7.0`.

The example below creates a client for the **Live** API by setting a base URI using the `\Http\Client\Common\Plugin\BaseUriPlugin` plugin. If you wish to use the **Sandbox** API, you can change the base URI from `https://alsoaskedapi.com/v1` to `https://sandbox.alsoaskedapi.com/v1`.

You'll need to change the API specified in the `\AlsoAsked\Api\Authentication\ApiKeyAuthentication` plugin from `your-api-key` to the API key you've created. If you don't have an API key, follow the [authentication guide](https://developers.alsoasked.com/docs/also-asked/j389o9lgezike-authentication).

```
