2017 © Pedro Peláez
 

library php-api-client

BaseKit PHP API client.

image

basekit/php-api-client

BaseKit PHP API client.

  • Friday, February 26, 2016
  • by markjeffries
  • Repository
  • 23 Watchers
  • 3 Stars
  • 534 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

BaseKit REST API Client

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., (*1)

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., (*2)

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., (*3)

Testing

Feed an optional handler into the config of clientFactory to control the responses from the http client., (*4)

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., (*5)

The Versions

26/02 2016

dev-master

9999999-dev

BaseKit PHP API client.

  Sources   Download

The Requires

 

The Development Requires

by Simon Best
by Ade Slade

09/02 2015

1.1.1

1.1.1.0

BaseKit PHP API client.

  Sources   Download

The Development Requires

by Simon Best
by Ade Slade

05/02 2015

2.0.0

2.0.0.0

BaseKit PHP API client.

  Sources   Download

The Requires

 

The Development Requires

by Simon Best
by Ade Slade

04/11 2014

1.0.0

1.0.0.0

BaseKit PHP API client.

  Sources   Download

The Development Requires

by Simon Best
by Ade Slade