Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfvandekrol committed Nov 23, 2023
1 parent 6be7a37 commit b27e964
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

All notable changes to `laravel-elastic` will be documented in this file.
All notable changes to `laravel-lti-provider` will be documented in this file.

Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Contributions are **welcome** and will be fully **credited**.

We accept contributions via Pull Requests on [Github](https://github.com/swisnl/laravel-elastic).
We accept contributions via Pull Requests on [Github](https://github.com/swisnl/laravel-lti-provider).


## Pull Requests
Expand Down
67 changes: 53 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
[![Total Downloads][ico-downloads]][link-downloads]
[![Made by SWIS][ico-swis]][link-swis]

This packages provides a bridge between the Celtic LTI Provider and Laravel models.
This packages provides a bridge between the [Celtic LTI Package](https://github.com/celtic-project/LTI-PHP) and Laravel
models, by implementing a DataConnector for the Celtic LTI Package.

## Install & Setup
## Install

Via Composer

``` bash
$ composer require swisnl/laravel-lti-provider
```

Then run command to copy the required files into your project.
Then run command to copy the required files (including the migrations) into your project.

```bash
php artisan lti-provider:install
Expand All @@ -32,25 +33,63 @@ If you have Laravel package auto discovery disabled, add the service provider to
];
```

The package comes with a very basic client implementation, but allows for overriding this implementation. To do so,
create a new class that implements the `Swis\Laravel\Lti\Contracts\LtiClient` interface and change the following to your
`config/lti-provider.php` file:
Finally run the migrations.

```bash
php artisan migrate
```

## Cron jobs

The package comes with a command to clean up expired LTI nonces. To run this command, add the following to your
`app/Console/Kernel.php` file:

```php
'client' => 'REFERENCE TO YOUR NEW CLASS',
protected function schedule(Schedule $schedule)
{
// ...
$schedule->command('lti-provider:delete-expired-nonces')->daily();
}
```

For inspiration on how to implement your own client, take a look at the `Swis\Laravel\Lti\Models\SimpleClient` class
(the very basic implementation) or the `\Workbench\App\OverrideModels\Client` class (this is a more complex example used
in the tests to check if it is possible to override the default implementation and if the package can handle clients
with UUIDs instead of numeric ids).
## Usage

After you have set up your client, you can run the migrations to create the required tables:
Define a model that you use as an LTI environment. This model should implement the
`Swis\Laravel\Lti\Contracts\LtiEnvironment`. The packages scopes all other models to the current LTI environment.

```bash
php artisan migrate
Using this this environment, you can create a new `ModelDataConnector` instance. This instance can be used like the
`DataConnector` from the Celtic LTI Package.

```php
$environment = MyLtiEnvironment::find($id);
$dataConnector = new ModelDataConnector($environment);
```

## Customization

This package allows overriding most of the models. We use this to override some models to use UUIDs instead of numeric
ids, and to add some extra functionality (examples of this extra functionality: adding logging to `UserResult`; and
using the same `Client` model for both LTI and [Laravel Passport](https://laravel.com/docs/10.x/passport)).

To override a model (except the client), create a new class that extends the original model and register the new model
in the `config/lti-provider.php` file. For example, to override the `UserResult` model, create a new class that extends
the `Swis\Laravel\Lti\Models\UserResult` class and change the following to your `config/lti-provider.php` file:

```php
'models' => [
'user-result' => 'REFERENCE TO YOUR NEW CLASS',
],
```

Clients are a bit different, because you don't need to extend from an existing class. To override the client, create a
new class that implements the `Swis\Laravel\Lti\Contracts\Client` interface and register the new model in the
`config/lti-provider.php` file.

For inspiration on how to implement your own client, take a look at the `Swis\Laravel\Lti\Models\SimpleClient` class
(a very basic implementation) or the `\Workbench\App\OverrideModels\Client` class (this is a more complex example used
in the tests to check if it is possible to override the default implementation and if the package can handle clients
with UUIDs instead of numeric ids).

## Change log

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
Expand Down

0 comments on commit b27e964

Please sign in to comment.