A PHP library to interact with the RESTful API of the Education Manager (EDM).
docker compose run --rm composer install
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);
$event = $client->event->findById(4711);
if ($event !== null)
echo $event['event_base_name'] . "\n";
}
$upcomingEvents = $client->event->findUpcoming();
foreach ($upcomingEvents as $event) {
echo $event['event_base_name'] . "\n";
}
$location = $client->category->findById(4711);
if ($category !== null)
echo $category['name'] . "\n";
}
$categories = $client->category->findAll();
foreach ($categories as $category) {
echo $category['name'] . "\n";
}
$location = $client->eventLocation->findById(4711);
if ($location !== null)
echo $location['name'] . "\n";
}
$locations = $client->eventLocation->findAll();
foreach ($locations as $location) {
echo $location['name'] . "\n";
}
$lecturer = $client->lecturer->findById(4711);
if ($lecturer !== null)
echo $lecturer['name'] . "\n";
}
$lecturers = $client->lecturer->findAll();
foreach ($lecturers as $lecturer) {
echo $lecturer['name'] . "\n";
}
$lecturer = $client->tag->findById(4711);
if ($tag !== null)
echo $tag['name'] . "\n";
}
$tags = $client->tag->findAll();
foreach ($tags as $tag) {
echo $tag['name'] . "\n";
}
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.
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'),
]);
Current PHPDocs can be viewed here: https://priorist.github.io/edm-sdk-php/
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
docker compose run --rm docs && open docs/index.html
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';