{"id":36980768,"url":"https://github.com/ozq/moodle-client","last_synced_at":"2026-01-13T22:50:32.718Z","repository":{"id":48385372,"uuid":"89053249","full_name":"ozq/moodle-client","owner":"ozq","description":"PHP client for moodle","archived":false,"fork":false,"pushed_at":"2021-07-28T20:29:41.000Z","size":20,"stargazers_count":24,"open_issues_count":3,"forks_count":40,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T01:52:58.116Z","etag":null,"topics":["client","moodle","php-client"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ozq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-22T07:45:39.000Z","updated_at":"2024-05-04T13:57:43.000Z","dependencies_parsed_at":"2022-08-24T00:31:08.143Z","dependency_job_id":null,"html_url":"https://github.com/ozq/moodle-client","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ozq/moodle-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozq%2Fmoodle-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozq%2Fmoodle-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozq%2Fmoodle-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozq%2Fmoodle-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ozq","download_url":"https://codeload.github.com/ozq/moodle-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ozq%2Fmoodle-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","moodle","php-client"],"created_at":"2026-01-13T22:50:31.997Z","updated_at":"2026-01-13T22:50:32.707Z","avatar_url":"https://github.com/ozq.png","language":"PHP","readme":"# MOODLE PHP CLIENT\n\n## Installation\nThe recommended way to install the library is through Composer:\n\n```\n$ composer require ozq/moodle-client:dev-master\n```\n \n## Usage\nCreate instance of connection with your moodle service: \n```php\n$connection = new Connection('http://url-to-moodle-service.com', 'Y0uR!tOken');\n```\n\nCreate instance of one of available moodle clients, e.g. REST client:\n```php\n$client = new RestClient($connection);\n```\n\nNow, you can use moodle services. There are available some build in ready to use moodle entities.\nAll logic and API working encapsulated in moodle services and entities. Let's create instance of Course service.\n \nCreate instance:\n ```\n $courseService = new Course($client);\n ```\n\nGet all courses:\n```php\n$courses = $courseService-\u003egetAll();\n```\n\nDelete courses with ids: 1, 2, 3:\n```php\n$courses = $courseService-\u003edelete([1, 2, 3]);\n```\n\nIf you have to send some specific structured data, e.g., when you create new course, it is better to use special DTO's objects:  \n```php\n$courseDto = new Course();\n$courseDto-\u003ename = 'Test Course';\n$courseDto-\u003efullName = 'Test Course fullname';\n...\n$courseService-\u003ecreate($courseDto);\n```\n\nIf there is no build in needed services and entities, you can create it.  \nServices must extend Service abstract class, entities (as DTO's) must extend Entity abstract class.  \n\nAlso, you can use moodle client without service layer:\n```php\n$courses = $client-\u003esendRequest('core_course_get_courses');\n```\n\n## Example of Laravel integration\n1. Create config file (config/moodle.php) for moodle service with content:  \n```php\n\u003c?php\n\nreturn [\n    'connection' =\u003e [\n        'url'   =\u003e 'http://url-to-moodle-service.com',\n        'token' =\u003e 'Y0uR!tOken',\n    ],\n];\n```\n\n2. Create service provider:  \n```\n$ php artisan make:provider MoodleServiceProvider\n```\nExample of MoodleServiceProvider register method:\n```php\npublic function register()\n{\n    $this-\u003eapp-\u003esingleton(ClientAdapterInterface::class, function () {\n        $connection = new Connection(config('moodle.connection.url'), config('moodle.connection.token'));\n        return new RestClient($connection);\n    });\n}\n```\n\n3. Register MoodleServiceProvider:  \nEdit your config/app.php, add ```\\App\\Providers\\MoodleServiceProvider::class```, to 'providers' array.\n\n4. Clear config cache:\n```\n$ php artisan clear-compiled\n$ php artisan config:clear\n```\n\n5. Now you can use Moodle services in your project:\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Ozq\\MoodleClient\\Services\\Course;\n\n/**\n * Class CourseController\n * @package App\\Http\\Controllers\n */\nclass CourseController extends Controller\n{\n    /**\n     * @var Course\n     */\n    protected $courseService;\n\n    /**\n     * CourseController constructor.\n     * @param Course $courseService\n     */\n    public function __construct(Course $courseService)\n    {\n        $this-\u003ecourseService = $courseService;\n    }\n\n    /**\n     * Display a listing of the resource.\n     *\n     * @return \\Illuminate\\Http\\Response\n     */\n    public function index()\n    {\n        $courses = $this-\u003ecourseService-\u003egetAll();\n        return view('courses.index', ['courses' =\u003e $courses]);\n    }\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozq%2Fmoodle-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fozq%2Fmoodle-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fozq%2Fmoodle-client/lists"}