PHP code example of cerpus / edlib-resource-kit
1. Go to this page and download the library: Download cerpus/edlib-resource-kit library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cerpus / edlib-resource-kit example snippets
use Cerpus\EdlibResourceKit\Lti\Lti11\Mapper\DeepLinking\ContentItemsMapper;
$mapper = new ContentItemsMapper();
$items = $mapper->map(<<<EOJSON
{
"@context": "http://purl.imsglobal.org/ctx/lti/v1/ContentItem",
"@graph": [
{
"@type": "LtiLinkItem",
"mediaType": "application/vnd.ims.lti.v1.ltilink",
"title": "My Cool LTI Content",
"url": "https://example.com/my-lti-content"
}
]
}
EOJSON);
echo count($items), "\n"; // 1
echo $items[0]->getTitle(), "\n"; // My Cool LTI Content
use Cerpus\EdlibResourceKit\Lti\Message\DeepLinking\LtiLinkItem;
use Cerpus\EdlibResourceKit\Lti\Lti11\Serializer\DeepLinking\ContentItemsSerializer;
$items = [
new LtiLinkItem(
mediaType: 'application/vnd.ims.lti.v1.ltilink',
title: 'My Cool LTI Content',
url: 'https://example.com/my-lti-content',
),
];
$serializer = new ContentItemsSerializer();
$serialized = $serializer->serialize($items);
echo json_encode($serialized);