This package is abandoned and no longer maintained. No replacement package was suggested.

PHP SDK for Moodle RESTful APIs

dev-master 2018-04-23 00:55 UTC

This package is not auto-updated.

Last update: 2020-05-01 18:44:51 UTC


PHP SDK for Moodle RESTful APIs

Build Status

Getting Started

  1. Install MoodleSDK

    php composer.phar require agurz/moodle-php-sdk
  2. Create a RestApiContext instance

    $context = new RestApiContext();
            ->setCredential(new AuthTokenCredential('token'))
  3. Create a model object instance, set it's properties and call get, create, update, or delete operations

    $user = new User();
         ->setFullName('first last')
  4. That's all!

Usage example

Creating a user and enrolling him into 'test-course' course


require_once 'vendor/autoload.php';

use MoodleSDK\Api\Model\Course;
use MoodleSDK\Api\Model\User;
use MoodleSDK\Auth\AuthTokenCredential;
use MoodleSDK\Rest\RestApiContext;

$context = RestApiContext::instance()
                         ->setCredential(new AuthTokenCredential('token'))

$user = User::instance()
            ->setFullName('Agustn Rodríguez')

$course = Course::instance()
                ->enrolUser($context, $user);