basekit/php-api-client

BaseKit PHP API client.

Package info

github.com/basekit/php-api-client

pkg:composer/basekit/php-api-client

Statistics

Installs: 4 762

Dependents: 1

Suggesters: 0

Stars: 2

Open Issues: 2

4.0.0 2023-06-28 13:15 UTC

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT bcd82c1bc18f4de81a3350df71de246394fb6cb5

  • Simon Best <simon.woop@basekit.com>
  • Ade Slade <adrian.slade.woop@basekit.com>

This package is not auto-updated.

Last update: 2026-06-25 04:19:40 UTC


README

A PHP client for BaseKit's REST API. This client will provide documentation of the services available from the BaseKit API, describing URIs, HTTP methods and input parameters.

Installation

The recommended way of including this package in your project is by using Composer. Add it to the require section of your project's composer.json.

composer require basekit/php-api-client

Usage

use BaseKit\Api\AuthType;
use BaseKit\Api\ClientFactory;

$client = ClientFactory::create(
 [
 'base_uri' => 'http://api.testing.com',
 'username' => 'foo',
 'password' => 'bar',
 ],
 AuthType::BASIC, // defaults to basic auth
);

$createSite = $client->getCommand(
 'CreateSite',
 [
 'accountHolderRef' => 123,
 'brandRef' => 789,
 'domain' => 'test.example.org',
 ]
);

$client->execute($createSite);

A more detailed example script is available here including account and site creation and populating a site with content using the API.

Testing

Feed an optional handler into the config of clientFactory to control the responses from the http client.

use BaseKit\Api\ClientFactory;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Psr7\Response;

$client = ClientFactory::create([
 'base_uri' => 'https://api.testing.com',
 'username' => 'foo',
 'password' => 'bar',
 'handler' => HandlerStack::create(
 new MockHandler([
 new Response(404, [], '"Hello, World! This is a test response."'),
 ])
 ) ,
]);

$createSite = $client->getCommand(
 'CreateSite',
 [
 'accountHolderRef' => 123,
 'brandRef' => 789,
 'domain' => 'test.example.org',
 ]
);

$client->execute($createSite); // Throws a 404 CommandClientException

License

This software is released under the MIT License.