daniieljc / laravel-moodle
Laravel Moodle Client
Installs: 2 070
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2024-11-18 20:21:08 UTC
README
This is a fork of ozq/moodle-client
daniieljc/laravel-moodle
is a Laravel package which created way to interact with moodle through api/webservice.
In adaptation and Work in Progress
Install
To install through Composer, by run the following command:
$ composer require daniieljc/laravel-moodle
The package will automatically register a service provider and alias.
Optionally, publish the package's configuration file by running:
php artisan vendor:publish --provider="Daniieljc\LaravelMoodle\LaravelMoodleServiceProvider"
Incorrect Documentation below
Installation
The recommended way to install the library is through Composer:
Usage
Create instance of moodle clients, e.g. REST client:
$client = new RestClient();
If there is no build in needed services and entities, you can create it.
Services must extend Service abstract class, entities (as DTO's) must extend Entity abstract class.
Also, you can use moodle client without service layer:
$courses = $client->sendRequest('core_course_get_courses', $parameters);
Real Example
use Daniieljc\LaravelMoodle\Clients\Adapters\RestClient; use Daniieljc\LaravelMoodle\Connection; use Daniieljc\LaravelMoodle\Services\Course; use Daniieljc\LaravelMoodle\Services\User; class Moodle { protected $client; public function __construct() { $this->client = new RestClient(); } public function getAllClient() { $service = new User($this->client); $users = $service->getAll(); } public function getEnRollUser() { $service = new Course($this->client); $courses = $service->getAll(); foreach ($courses as $course) { $enroll = $service->getCourseEnRolledUser($course->id); } } }