README.textile 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. h1. Introduction
  2. This library is an implementation of the PENS specification (see http://pens.lmstesting.com/pages/whatispens.htm) in PHP. It provides a PENSServer class and, in the future, will provide a PENSClient class.
  3. h1. Requirements
  4. You need at least PHP 5.2 with the curl extension installed to use this library.
  5. h1. State
  6. Currently, some features are missing (such as the possibility to send alerts or the possibility to send receipts to a mailto url), and the library is not considered as stable.
  7. h1. How do I create a server ?
  8. Assuming the URL of your server is http://www.myserver.com, create a file called pens.php at the root so that it is accessible through http://www.myserver.com/pens.php.
  9. In this file, write the following code:
  10. pre.. // Assuming the library is accessible through pens/pens.php
  11. require_once("pens/pens.php");
  12. // Create a concrete class that extends PENSPackageHandler and
  13. // write your implementation of the processPackage method in it
  14. class MyPackageHandler extends PENSPackageHandler {
  15. // See the documentation of the processPackage method for more information
  16. public function processPackage($request, $path_to_package) {
  17. // Write your implementation of the package handling here
  18. }
  19. }
  20. // Create an instance of your handler and configure it
  21. // See the file pens_package_handler.php for more information
  22. $handler = new MyPackageHandler();
  23. $handler->setSupportedPackageTypes(array("scorm-pif"));
  24. $handler->setSupportedPackageFormats(array("zip"));
  25. // Initialize the server
  26. $server = PENSServer::singleton();
  27. $server->setPackageHandler($handler);
  28. // The server should only receive collect commands, so call the receiveCollect method
  29. $server->receiveCollect();
  30. h1. How do I create a client ?
  31. The role of the PENSClient is simply to receive receipts and alerts from the server and process them. Here is how to create a client.
  32. pre.. require_once("pens/pens.php");
  33. // Create a request handler if you need one. This allows you to do some processing on the requests (store them in a DB, send them to an email address etc...)
  34. // You do not need to create a request handler if you do not want to process the requests
  35. class MyRequestHandler extends PENSRequestHandler {
  36. public function processRequest($request, $response) {
  37. // Do the processing of the alert or the receipt here
  38. }
  39. }
  40. // Instantiate the handler
  41. $handler = new MyRequestHandler();
  42. // Create the client and set the request handler
  43. $client = PENSClient::singleton();
  44. $client->setRequestHandler($handler);
  45. // Parse and process the request
  46. $client->receiveRequest();
  47. h1. Licence
  48. The php-pens library is published under the GNU GPL 3 licence (see COPYING)
  49. h1. Credits
  50. The author of the library is Guillaume Viguier-Just <guillaume@viguierjust.com> and this library has been realized mainly for use in the Chamilo project (http://www.chamilo.org).
  51. This library was realized as part of my work in Beeznest Latino (http://www.beeznest.com), for the Chamilo project.
  52. Also note the use of a library called rfc2396regexes written by Rudy Desjardins and distributed as GPL v2