A library used for building IMS-certified LTI 1.3 tool providers in PHP.
This library allows a tool provider (your app) to receive LTI launches from a tool consumer (i.e. LMS). It validates LTI launches and lets an application interact with services like the Names Roles Provisioning Service (to fetch a roster for an LMS course) and Assignment Grades Service (to update grades for students in a course in the LMS).
This library was forked from IMSGlobal/lti-1-3-php-library, initially created by @MartinLenord. Packback found the library immensely helpful and extended it over the years. It has been rewritten by Packback to bring it into compliance with the standards set out by the PHP-FIG and the IMS LTI 1.3 Certification process. Packback actively uses and maintains this library.
Run:
composer require packbackbooks/lti-1p3-tool
In your code, you will now be able to use classes in the Packback\Lti1p3
namespace to access the library.
Add the following when bootstrapping your app.
Firebase\JWT\JWT::$leeway = 5;
This library uses three methods for storing and accessing data: cache, cookie, and database. All three must be implemented in order for the library to work. You may create your own custom implementations so long as they adhere to the following interfaces:
Packback\Lti1p3\Interfaces\ICache
Packback\Lti1p3\Interfaces\ICookie
Packback\Lti1p3\Interfaces\IDatabase
View the Laravel Implementation Guide to see examples (or copy/paste the code outright). Cache and Cookie storage have legacy implementations at Packback\Lti1p3\ImsStorage\
if you do not wish to implement your own. However, you must implement your own database.
A JWKS (JSON Web Key Set) endpoint can be generated for either an individual registration or from an array of KID
s and private keys.
use Packback\Lti1p3\JwksEndpoint;
// From issuer
JwksEndpoint::fromIssuer($database, 'http://example.com')->outputJwks();
// From registration
JwksEndpoint::fromRegistration($registration)->outputJwks();
// From array
JwksEndpoint::new(['a_unique_KID' => file_get_contents('/path/to/private/key.pem')])->outputJwks();
The wiki provides more detailed information about how to use this library, including a Laravel Implementation Guide.
For improvements, suggestions or bug fixes, make a pull request or an issue. Before opening a pull request, add automated tests for your changes, ensure that all tests pass, and any linting errors are fixed.
Automated tests can be run using the command:
composer test
Linting can be run using
# Display linting errors
composer lint
# Automatically fix linting errors
composer lint-fix