packbackbooks / lti-1-3-php-library

A library used for building IMS-certified LTI 1.3 tool providers in PHP.
Apache License 2.0
39 stars 25 forks source link

How make a full implementation #69

Open sebitaas96-ss opened 2 years ago

sebitaas96-ss commented 2 years ago

Good morning ,

Has anyone managed to make a complete implementation of this Lti-1-3 package, we would be grateful if you could share the information with us.

thanks.

dbhynds commented 1 year ago

We're actively using this in our product. We use it for launches, AGS, and NRPS. We don't currently use deep linking, but others do. I haven't had time to mock up a full demo implementation, but if there are specific things you have questions about, I'm happy to answer them.

I'm assuming you've seen it already, but if not we have some information in the wiki: https://github.com/packbackbooks/lti-1-3-php-library/wiki If you have suggestions of how to improve it, I'd love to hear them.

battis commented 1 year ago

Digging into the documentation, and I see that the the example implementation in the documentation refers to App\Models\Issuer and App\Models\Deployment -- which I infer an implementation needs to define? Is there guidance on what these models need to include?

battis commented 1 year ago

FWIW, I've been poking at this, the missing piece is really the model migrations for Issuer and Deployment. I'm still futzing with getting this up and running on Google App Engine (it's own special problem), but my notes from getting this set up so far, which I include here rather than editing the wiki because I have limited confidence:

Working from the Laravel impelementation guide:

curl -s "https://laravel.build/<lti-tool-name>" | bash
cd <lti-tool-name>
composer require packbackbooks/lti-1p3-tool firebase/php-jwt
rm app/Models/User.php
php artisan make:model Issuer --all

In database/migrations/<timestamp>_create_issuer_table.php in up():

$table->string('auth_token_url');
$table->string('auth_login_url');
$table->string('client_id');
$table->string('key_set_url');
$table->string('kid');
$table->string('issuer');
$table->string('tool_private_key');
php artisan make:model Deployment --all

In database/migrations/<timestamp>_create_deployment_table.php in up():

$table->string('deployment_id');

Copy-paste app/Providers/AppServiceProvider.php from wiki then add:

use Packback\Lti1p3\LtiServiceConnector;

Copy-paste app/Lti13Cache.php from wiki, then add:

use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;

Copy-paste app/Lti13Cookie.php from wiki:

Copy-paste app/Lti13Database.php from wiki.

mkdir app/Services

Copy-paste app/Services/Lti13Service.php from wiki.

Throughout, add namespaces as appropriate.

dbhynds commented 1 year ago

You'll probably want a foreign key from the Deployment to the Issuer. That way you can query on that relation, since there is almost guaranteed to be a collision in deployment_id if you have more than one instance of the same type of LMS integrating with your tool. You'll need to be able to do

// This:
$issuer->deployments()->where('deployment_id', $deploymentId)->first();
// Not this:
Deployment::where('deployment_id', $deploymentId)->first();
datavoyager commented 8 months ago

You'll probably want a foreign key from the Deployment to the Issuer. That way you can query on that relation, since there is almost guaranteed to be a collision in deployment_id if you have more than one instance of the same type of LMS integrating with your tool. You'll need to be able to do

// This:
$issuer->deployments()->where('deployment_id', $deploymentId)->first();
// Not this:
Deployment::where('deployment_id', $deploymentId)->first();

Can you let me know where this code goes? Is it in the issuer migration file or is it already part of the code base in findDeployment?