PHP code example of petersons / d2l-client

1. Go to this page and download the library: Download petersons/d2l-client 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/ */

    

petersons / d2l-client example snippets


use Petersons\D2L\AuthenticatedUriFactory;
use Petersons\D2L\DTO\Enrollment\CreateEnrollment;
use Petersons\D2L\SymfonyHttpClient;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\ScopingHttpClient;

$client = new SymfonyHttpClient(
            ScopingHttpClient::forBaseUri(
                HttpClient::create(),
                'https://petersonstest.brightspace.com',
            ),
            new AuthenticatedUriFactory(
                'https://petersonstest.brightspace.com',
                'appId',
                'appKey',
                'lmsUserId',
                'lmsUserKey',
            ),
            'orgId',
            'installationCode',
            'pKey',
            'apiLpVersion', // e.g. 1.30
            'apiLeVersion', // e.g. 1.53
        );

$client->enrollUser(new CreateEnrollment(1, 2, 3));
bash
php artisan vendor:publish --tag=d2l-config
bash
    dev/bin/docker-compose build --build-arg PHP_VERSION=8.2 php
    
bash
    dev/bin/php composer update
    
bash
    dev/bin/php-test vendor/bin/php-cs-fixer fix