dcarbone/amber-hat

Lib designed to help PHP apps consume from REDCap's API

0.4.2 2015-12-18 22:50 UTC

This package is auto-updated.

Last update: 2024-04-17 08:50:29 UTC


README

A REDCap Client library written in PHP

Installation

This lib requires the use of Composer.

"require": {
    "dcarbone/amber-hat": "0.4.*"
}

Client Creation

To get started, you will need 3 things:

  1. Full URL to your REDCap installation's API endpoint (typically something like "https://redcap.mygreatinstitution.edu/api/")
  2. A REDCap API token
  3. A Temp directory on the server capable of handling potentially large files

Once you have those, you can immediately start exporting data for the project the token gives you access to:

use DCarbone\AmberHat\AmberHatClient;

$client = new AmberHatClient(
    'https://redcap.mygreatinstitution.edu/api/',
    'mygreattoken',
    'my-cache-dir');  

Available Data Export methods:

Basic Export Data Object Structure

With the exception of Records, Project Information, and Record Field File, all export methods return a collection class which extends AbstractItemCollection. This collection class implements the following interfaces:

The objects present in the collection are all classes which implement the ItemInterface interface. The interface requires concrete classes to implement the following:

NOTE: For PHP 5.3 users, I have created a JsonSerializableCompatible interface, however you must execute json_encode on the result of the implemented method call, rather than on the object itself.

Ex:

$json_string = json_encode($itemObject->jsonSerialize());

Available Data Import methods:

At the moment, no import methods are available. However, this feature is being worked on and will hopefully come to fruition soon.