Loco SDK for PHP, including REST API client

1.0.18 2017-10-09 15:53 UTC



Installation is via Composer.

Add the latest stable version of loco/loco to your project's composer.json file as follows:

"require": {
  "loco/loco": "~1.0"

If you want to install straight from Github you'll have to write your own autoloader for now.


The SDK includes a REST client for the Loco API.

Client Usage

Basic usage of the client is to construct with your API key and call the endpoint methods directly. The following example simply verifies your credentials:

$client = Loco\Http\ApiClient::factory( array( 'key' => 'your_api_key' ) );
$result = $client->authVerify();
printf("Authenticated as '%s'\n", $result['user']['name'] );

The Loco API client is built on Guzzle 3. You can use its factory methods to configure your API Key as above, or you can use a JSON config like our example. Constructing from the config file can be done as follows:

$client = Guzzle\Service\Builder\ServiceBuilder::factory('config.json' )->get('loco');

Command Line Client

A Console interface supporting all methods of the Loco API is at bin/console. Just run it to see all the available options.

The console reads from config.json, but you can override your API key from the command line. Run the following to verify your credentials:

bin/console loco:auth:verify -v -k <your_api_key> 


Check the Loco API documentation to see what model is returned from each end point.

See the example directory for more working code examples.

Build the PHP API documentation with apigen using apigen -c apigen.yml