Skip to content

This repository contains the LORIS PHP API client, a PHP client to interact with the LORIS public HTTP API.

Notifications You must be signed in to change notification settings

aces/loris-php-api-client

Repository files navigation

LORIS PHP API Client

API for interacting with the LORIS Platform

This PHP package is automatically generated by the OpenAPI Generator project:

  • API version: 0.0.4
  • Build package: openapi-generator (php)
  • OpenAPI specification: schema.yml

For more information, please visit https://github.com/aces/Loris

Requirements

PHP 8.1 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/aces/loris-php-client.git"
    }
  ],
  "require": {
    "loris/php-client": "dev-main"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

require_once('/path/to/loris-php-client/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

use LORISClient\Configuration;
use LORISClient\Api\AuthenticationApi;
use LORISClient\Api\ClinicalApi;
use GuzzleHttp\Client;

// Configure API client
$config = Configuration::getDefaultConfiguration()
    ->setHost('https://loris.example.com/api/v0.0.3');

$httpClient = new Client(['verify' => true]);

// Authenticate and get token
$authApi = new AuthenticationApi($httpClient, $config);

try {
    $result = $authApi->authenticate([
        'username' => 'your_username',
        'password' => 'your_password'
    ]);
    
    $token = $result['token'];
    
    // Configure API with token
    $config->setAccessToken($token);
    
    // Use the Clinical API
    $clinicalApi = new ClinicalApi($httpClient, $config);
    
    
} catch (Exception $e) {
    echo 'Exception: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

All URIs are relative to your LORIS instance API endpoint (e.g., https://loris.example.com/api/v0.0.3)

Class Method HTTP request Description
AuthenticationApi authenticate POST /login Authenticate and obtain JWT token
ClinicalApi getInstruments GET /instruments Get list of instruments
ClinicalApi getCandidates GET /candidates Get list of candidates
ClinicalApi createCandidate POST /candidates Create a new candidate
ClinicalApi getCandidate GET /candidates/{candID} Get candidate details
ClinicalApi getVisit GET /candidates/{candID}/{visitLabel} Get visit information
ClinicalApi createTimepoint PUT /candidates/{candID}/{visitLabel} Create timepoint/visit
ClinicalApi getInstrumentData GET /candidates/{candID}/{visitLabel}/instruments/{instrument} Get instrument data
ClinicalApi uploadInstrumentData PUT /candidates/{candID}/{visitLabel}/instruments/{instrument} Upload instrument data
ClinicalApi uploadInstrumentCSV POST /instrument_manager/instrument_data Bulk upload instrument data via CSV

Documentation For Models

Documentation For Authorization

BearerAuth

  • Type: HTTP Bearer Token authentication
  • Bearer format: JWT
  • Description: JWT token obtained from /login endpoint

Example:

$config = Configuration::getDefaultConfiguration()
    ->setAccessToken('YOUR_JWT_TOKEN');

Development

This client is generated from the OpenAPI specification using OpenAPI Generator.

To regenerate the client:

./generate.sh

Or manually:

openapi-generator-cli generate \
  -i schema.yml \
  -g php \
  -o . \
  -c openapi-config.json \
  --additional-properties=composerPackageName=loris/php-client

API Version Compatibility

This client supports LORIS API versions:

  • v0.0.3
  • v0.0.4

Configure the version in the base URL:

$config->setHost('https://loris.example.com/api/v0.0.3');

Contributing

Issues and pull requests are welcome on GitHub.

License

GPL-3.0

Related Projects

  • LORIS - Longitudinal Online Research and Imaging System

Author

The LORIS Team

About

This repository contains the LORIS PHP API client, a PHP client to interact with the LORIS public HTTP API.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published