Skip to content

Commit

Permalink
Merge pull request #7 from swisnl/feature/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
tommie1001 authored Nov 22, 2023
2 parents 48b8330 + e4d0d73 commit 439435c
Show file tree
Hide file tree
Showing 55 changed files with 2,070 additions and 711 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
/art export-ignore
/docs export-ignore
/tests export-ignore
/workbench export-ignore
/.editorconfig export-ignore
/.php_cs.dist.php export-ignore
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/UPGRADING.md export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
20 changes: 0 additions & 20 deletions Commands/DeleteExpiredLtiNonces.php

This file was deleted.

41 changes: 34 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# laravel-lti-provider
# Laravel LTI Provider

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
Expand All @@ -7,22 +7,49 @@
[![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.



## Install
## Install & Setup

Via Composer

``` bash
$ composer require swisnl/laravel-lti-provider
```
## Usage
Run

Then run command to copy the required files into your project.

```bash
php artisan lti-service-provider:install
```
implemnent the LtiClient interface to your oauth2 client model. Implement the methods and add the required attributes

If you have Laravel package auto discovery disabled, add the service provider to your `config/app.php` file:

```php
'providers' => [
// ...
Swis\Laravel\Lti\Providers\LtiServiceProvider::class,
];
```

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:

```php
'lti-client' => 'REFERENCE TO YOUR NEW CLASS',
```

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).

After you have set up your client, you can run the migrations to create the required tables:

```bash
php artisan migrate
```

## Change log

Expand Down
38 changes: 26 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
"nunomaduro/collision": "^7.8",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.8",
"pestphp/pest": "^2.20",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
Expand All @@ -42,22 +39,31 @@
}
},
"scripts": {
"post-autoload-dump": "@composer run prepare",
"post-autoload-dump": [
"@clear",
"@prepare",
"@composer run prepare"
],
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
"@php vendor/bin/testbench workbench:build --ansi"
],
"build": "@php vendor/bin/testbench workbench:build --ansi",
"start": [
"Composer\\Config::disableProcessTimeout",
"@composer run build",
"@php vendor/bin/testbench serve"
],
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/pint"
"test": "vendor/bin/phpunit",
"format": "vendor/bin/pint",
"serve": [
"Composer\\Config::disableProcessTimeout",
"@build",
"@php vendor/bin/testbench serve"
],
"lint": [
"@php vendor/bin/pint",
"@php vendor/bin/phpstan analyse"
]
},
"extra": {
"laravel": {
Expand All @@ -75,5 +81,13 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/",
"Workbench\\App\\": "workbench/app/",
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
}
}
}
14 changes: 8 additions & 6 deletions config/lti-provider.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

return [
'lti-client' => '',
'lti-context' => \Swis\Laravel\LtiProvider\Models\LtiContext::class,
'lti-resource-link' => \Swis\Laravel\LtiProvider\Models\LtiResourceLink::class,
'lti-nonce' => \Swis\Laravel\LtiProvider\Models\LtiNonce::class,
'lti-user-result' => \Swis\Laravel\LtiProvider\Models\LtiUserResult::class,
'lti-access-token' => \Swis\Laravel\LtiProvider\Models\LtiAccessToken::class,
'class-names' => [
'lti-client' => \Swis\Laravel\LtiProvider\Models\SimpleClient::class,
'lti-context' => \Swis\Laravel\LtiProvider\Models\LtiContext::class,
'lti-resource-link' => \Swis\Laravel\LtiProvider\Models\LtiResourceLink::class,
'lti-nonce' => \Swis\Laravel\LtiProvider\Models\LtiNonce::class,
'lti-user-result' => \Swis\Laravel\LtiProvider\Models\LtiUserResult::class,
'lti-access-token' => \Swis\Laravel\LtiProvider\Models\LtiAccessToken::class,
],
];
Loading

0 comments on commit 439435c

Please sign in to comment.