Using the PHP LTI classes
Use require or require_once to include the class library file in your application. For further information on this library see the LTI classes documentation.
Set up a connection to the database containing the LTI tables; these tables are documented in an entity-relationship diagram.
Sample code
The init.php file:
- includes the class library
- creates a SQLite database file
- create the LTI database tables
- initialises a tool consumer for "jisc.ac.uk"
- enables this consumer key if it does not already exist and saves the record
After running this script you can use this link to inspect and manage the database.
init.php
<?php // Load LTI classes require_once('LTI_Tool_Provider.php'); $db = new PDO('sqlite:lti-workshop.sqlitedb'); // Initialise tool consumer record if it does not already exist $consumer = new LTI_Tool_Consumer('jisc.ac.uk', $db); if (is_null($consumer->created)) { $consumer->name = 'ceLTIc'; $consumer->secret = 'secret'; $consumer->enabled = TRUE; $consumer->save(); } ?>