定制 michaelmeneses/moodle-stubs 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michaelmeneses/moodle-stubs

Composer 安装命令:

composer require michaelmeneses/moodle-stubs

包简介

PHP stubs for Moodle LMS — classes, functions, constants, and global variables for IDE and static analysis support

README 文档

README

PHP stub files for the Moodle LMS codebase. Provides IDE autocompletion and static analysis support for Moodle's classes, functions, constants, and global variables — without requiring a full Moodle installation.

Ideal for Moodle plugin developers, theme developers, and anyone working with Moodle's PHP API outside of a full Moodle environment.

Installation

composer require --dev michaelmeneses/moodle-stubs

To pin to a specific Moodle version:

# Latest patch for Moodle 4.3.x
composer require --dev michaelmeneses/moodle-stubs:^4.3

# Latest patch for Moodle 5.0.x
composer require --dev michaelmeneses/moodle-stubs:^5.0

# Exact version
composer require --dev michaelmeneses/moodle-stubs:4.3.2

Usage

PHPStan

Add to your phpstan.neon:

parameters:
    scanDirectories:
        - vendor/michaelmeneses/moodle-stubs/stubs

Now PHPStan recognizes all Moodle classes, functions, and globals:

// PHPStan knows $DB is moodle_database, $CFG is stdClass, etc.
global $DB, $CFG;

$record = $DB->get_record('user', ['id' => 1]); // Fully typed
$wwwroot = $CFG->wwwroot; // No "undefined property" errors

Psalm

Add to your psalm.xml:

<psalm>
    <stubs>
        <dir name="vendor/michaelmeneses/moodle-stubs/stubs"/>
    </stubs>
</psalm>

Rector

Rector uses PHPStan internally. Add the PHPStan configuration above and Rector will pick it up automatically.

PhpStorm

Stubs are detected automatically via Composer. If autocompletion is not working, mark the vendor/michaelmeneses/moodle-stubs/stubs directory as a Sources Root (right-click > Mark Directory as > Sources Root).

VS Code (Intelephense)

Intelephense picks up stubs from Composer dependencies automatically. No extra configuration needed.

What's Included

  • Classes, interfaces, traits, and enums — full declarations with method signatures, type hints, and PHPDoc
  • Functions — all procedural functions from Moodle core libraries (lib/moodlelib.php, lib/weblib.php, lib/accesslib.php, etc.)
  • Constants — both define() and const declarations (MOODLE_INTERNAL, PARAM_INT, CONTEXT_*, etc.)
  • Global variables$DB, $CFG, $USER, $PAGE, $OUTPUT, $SESSION, $COURSE, $SITE with correct type annotations
  • Full coverage — all PHP files in the Moodle codebase, not just core libraries

All implementation bodies are stripped — only declarations and signatures are preserved.

Versions

Each Moodle release branch and version tag has a corresponding branch/tag in this repository:

This repository Moodle source Use case
Tag v4.3.2 Moodle release v4.3.2 Pin to a specific release (recommended for production)
Tag v5.0.0 Moodle release v5.0.0 Pin to a specific release
Branch MOODLE_403_STABLE Latest MOODLE_403_STABLE Track latest patches for 4.3.x
Branch MOODLE_500_STABLE Latest MOODLE_500_STABLE Track latest patches for 5.0.x
Branch master Latest Moodle master Bleeding edge development

Branches are updated weekly. Tags are immutable — once created, they never change.

How It Works

Stubs are auto-generated by bimoo, an AST-based stub generator built with nikic/php-parser. A GitHub Actions workflow runs weekly to:

  1. Detect new commits in Moodle's official repository
  2. Regenerate stubs only for branches that changed (SHA-based tracking)
  3. Create tags for new Moodle releases automatically

Sponsors

MIDDAG

Maintained by Michael Meneses and supported by MIDDAG — Moodle development and technical services.

Building Moodle plugins? Check out MIDDAG for Moodle — a plugin suite and development framework that brings modern developer experience to Moodle, inspired by tools like Symfony and Laravel.

Credits

Based on the original machitgarha/bimoo project by Mohammad Amin Chitgarha.

License

Licensed under GPL 3.0.

统计信息

  • 总下载量: 350
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2026-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固