https://github.com/dan-leech/moodle-php-sdk
Unofficial SDK for Moodle REST APIs written in PHP
https://github.com/dan-leech/moodle-php-sdk
Last synced: 5 months ago
JSON representation
Unofficial SDK for Moodle REST APIs written in PHP
- Host: GitHub
- URL: https://github.com/dan-leech/moodle-php-sdk
- Owner: dan-leech
- License: mit
- Fork: true (visol-forks/moodle-php-sdk)
- Created: 2020-03-10T10:23:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-13T21:36:44.000Z (over 6 years ago)
- Last Synced: 2025-08-21T21:32:44.600Z (10 months ago)
- Language: PHP
- Homepage:
- Size: 107 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moodle-PHP-SDK
PHP SDK for Moodle RESTful APIs
[](https://travis-ci.org/agurodriguez/moodle-php-sdk)
## Getting Started
1. Install MoodleSDK
```
php composer.phar require agurz/moodle-php-sdk
```
2. Create a `RestApiContext` instance
```php
$context = new RestApiContext();
$context->setUrl('example.com/moodle')
->setCredential(new AuthTokenCredential('token'))
```
3. Create a model object instance, set it's properties and call `get`, `create`, `update`, or `delete` operations
```php
$user = new User();
$user->setUsername('username')
->setPassword('Password..01')
->setFirstName('first')
->setLastName('last')
->setFullName('first last')
->setEmail('test@example.com')
->create($context)
```
4. That's all!
## Usage example
### Creating a user and enrolling him into 'test-course' course
```php
setUrl('example.com/moodle')
->setCredential(new AuthTokenCredential('token'))
$user = User::instance()
->setUsername('agurz')
->setPassword('Password..01')
->setFirstName('Agustn')
->setLastName('Rodríguez')
->setFullName('Agustn Rodríguez')
->setEmail('test@example.com')
->create($context);
$course = Course::instance()
->setShortName('test-course')
->get($context)
->enrolUser($context, $user);
```