dcarbone / amber-hat
Lib designed to help PHP apps consume from REDCap's API
Requires
- php: >=5.3.3
- ext-curl: *
- ext-date: *
- ext-libxml: *
- ext-mbstring: *
- ext-pcre: *
- ext-spl: *
- lib-curl: *
- lib-libxml: *
- lib-pcre: *
- dcarbone/curl-plus: 2.0.*
Suggests
- ext-openssl: For that SSL goodness.
- lib-openssl
This package is auto-updated.
Last update: 2024-11-17 10:03:45 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:
- Full URL to your REDCap installation's API endpoint (typically something like "https://redcap.mygreatinstitution.edu/api/")
- A REDCap API token
- 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:
- Arms
- Events
- Metadata
- Export Field Names
- Project Information
- Form Events
- Users
- Instruments (forms)
- Records
- Record Field File
- Version
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.