priorist / edm-sdk
A PHP library to interact with the RESTful API of the Education Manager (EDM).
Requires
- php: ^7.4.1 || ^8.0
- guzzlehttp/guzzle: ^6.5.8 || ^7.0.0
- league/oauth2-client: ^2.4
Requires (Dev)
- phpunit/phpunit: ^12.0
This package is auto-updated.
Last update: 2026-03-20 11:37:11 UTC
README
A PHP library to interact with the RESTful API of the Education Manager (EDM).
Install with Composer
docker compose run --rm composer install
Usage
Init client
use Priorist\EDM\Client\Client; $client = new Client('https://edm.example.com', 'CLIENT_ID', 'CLIENT_SECRET'); // $client now works with global permission, e.g. to read events. $events = $client->event->findUpcoming(); // To switch to permissions of a given user, e.g. to read participant data, call logIn // with the user’s login name and password: $accessToken = $client->logIn('USER_NAME', 'PASSWORD'); $client->event->findParticipating(); // You may store $accessToken in your session to re-use it later: $client->setAccessToken($accessToken);
Events
Single event for a given ID
$event = $client->event->findById(4711); if ($event !== null) echo $event['event_base_name'] . "\n"; }
List of upcoming events
$upcomingEvents = $client->event->findUpcoming(); foreach ($upcomingEvents as $event) { echo $event['event_base_name'] . "\n"; }
Categories
Single category for a given ID
$location = $client->category->findById(4711); if ($category !== null) echo $category['name'] . "\n"; }
List of all categories
$categories = $client->category->findAll(); foreach ($categories as $category) { echo $category['name'] . "\n"; }
Event locations
Single location for a given ID
$location = $client->eventLocation->findById(4711); if ($location !== null) echo $location['name'] . "\n"; }
List of all locations
$locations = $client->eventLocation->findAll(); foreach ($locations as $location) { echo $location['name'] . "\n"; }
Lecturers
Single lecturer for a given ID
$lecturer = $client->lecturer->findById(4711); if ($lecturer !== null) echo $lecturer['name'] . "\n"; }
List of all lecturers
$lecturers = $client->lecturer->findAll(); foreach ($lecturers as $lecturer) { echo $lecturer['name'] . "\n"; }
Tags
Single tag for a given ID
$lecturer = $client->tag->findById(4711); if ($tag !== null) echo $tag['name'] . "\n"; }
List of all tags
$tags = $client->tag->findAll(); foreach ($tags as $tag) { echo $tag['name'] . "\n"; }
Enrollments
Enroll for a given event
use Priorist\EDM\Client\Rest\ClientException; $enrollment = [ 'first_name' => 'John', 'last_name' => 'Doe', 'event' => 4711, 'price' => 4712, ]; try { $enrollment = $client->enrollment->create($enrollment); } catch (ClientException $e) { $errors = $e->getDetails(); // Contains errors for missing/invalid fields/values } echo $enrollment['id']; // Holds the resulting ID on success.
Users
Create user
use Priorist\EDM\Client\Rest\ClientException; $user = [ 'first_name' => 'John', 'last_name' => 'Doe', 'title' => 'M', 'main_contact_info' => [ 'email' => 'john@doe.com' ], 'prevent_duplicates' => true, ]; try { $user = $client->user->create($user); } catch (ClientException $e) { $errors = $e->getDetails(); // Contains errors for missing/invalid fields/values } echo $user['id']; // Holds the resulting ID on success.
User Lists
Add user to list(s)
use Priorist\EDM\Client\Rest\ClientException; $lists = [ 'data' => [ 'list_data' => [ [ 'user_list' => 1, 'user' => 42, ], [ 'user_list' => 2, 'user' => 42, ], ], 'consent_method' => 'trigger_confirmation', ] ]; try { $lists = $client->userList->createBulk($lists); } catch (ClientException $e) { $errors = $e->getDetails(); // Contains errors for missing/invalid fields/values }
Generic requests
If you do not find a suitable method of a given repository, you may use the more
generic methods fetchCollection($params = []) and fetchSingle(int $id, array $params = []).
E.g. $client->event->findUpcoming() equals
$client->event->fetchCollection([ 'ordering' => 'first_day', 'first_day__gte' => date('Y-m-d'), ]);
You can even call any endpoint you like, even the ones without an actual repository:
$client->getRestClient()->fetchCollection('events', [ 'ordering' => 'first_day', 'first_day__gte' => date('Y-m-d'), ]);
Class docs
Current PHPDocs can be viewed here: https://priorist.github.io/edm-sdk-php/
Run tests
Enable compose.override.yml and run
docker compose run --rm test
XDebug support for Docker for Mac included.
To create and view a detailed, browsable test coverage report run
docker compose run --rm test tests --coverage-html test_results/coverage && open test_results/coverage/index.html
Generate docs
docker compose run --rm docs && open docs/index.html
Build *.phar archive
To use the SDK in legacy applications, you may build and include a *.phar package in your application.
Download phar-composer first:
curl --location --output phar-composer.phar https://clue.engineering/phar-composer-latest.phar
Build the archive:
docker compose run --rm phar
To use the client, include the autoload of the archive:
include 'edm-sdk.phar/vendor/autoload.php';