PHPackages                             michaelmeneses/moodle-stubs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. michaelmeneses/moodle-stubs

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

michaelmeneses/moodle-stubs
===========================

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

v5.2.0(1mo ago)0323↑100%GPL-3.0-or-laterPHP ^8.1CI passing

Since Apr 12Pushed 3d agoCompare

[ Source](https://github.com/michaelmeneses/moodle-stubs)[ Packagist](https://packagist.org/packages/michaelmeneses/moodle-stubs)[ RSS](/packages/michaelmeneses-moodle-stubs/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (139)Used By (0)

Moodle Stubs
============

[](#moodle-stubs)

PHP stub files for the [Moodle LMS](https://moodle.org/) 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
------------

[](#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
-----

[](#usage)

### PHPStan

[](#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

[](#psalm)

Add to your `psalm.xml`:

```

```

### Rector

[](#rector)

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

### PhpStorm

[](#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 &gt; Mark Directory as &gt; Sources Root).

### VS Code (Intelephense)

[](#vs-code-intelephense)

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

What's Included
---------------

[](#whats-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
--------

[](#versions)

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

This repositoryMoodle sourceUse caseTag `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 releaseBranch `MOODLE_403_STABLE`Latest `MOODLE_403_STABLE`Track latest patches for 4.3.xBranch `MOODLE_500_STABLE`Latest `MOODLE_500_STABLE`Track latest patches for 5.0.xBranch `master`Latest Moodle `master`Bleeding edge developmentBranches are updated weekly. Tags are immutable — once created, they never change.

How It Works
------------

[](#how-it-works)

Stubs are auto-generated by [bimoo](https://github.com/michaelmeneses/bimoo), an AST-based stub generator built with [nikic/php-parser](https://github.com/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
--------

[](#sponsors)

[![MIDDAG](https://camo.githubusercontent.com/250fb77575f8f899cedf8aa1c10d3dc918b014b9ee3f2b7ba64d9c0491267cbc/68747470733a2f2f6d69646461672e636f6d2e62722f6173736574732f6c6f676f)](https://middag.com.br)

Maintained by [Michael Meneses](https://github.com/michaelmeneses) and supported by **[MIDDAG](https://middag.com.br)** — Moodle development and technical services.

Building Moodle plugins? Check out **[MIDDAG for Moodle](https://middag.io)** — a plugin suite and development framework that brings modern developer experience to Moodle, inspired by tools like Symfony and Laravel.

Credits
-------

[](#credits)

Based on the original [machitgarha/bimoo](https://github.com/machitgarha/bimoo) project by [Mohammad Amin Chitgarha](https://github.com/machitgarha).

License
-------

[](#license)

Licensed under [GPL 3.0](./LICENSE).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance95

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

100

Last Release

50d ago

Major Versions

v4.1.21 → v5.0.42026-04-12

v4.1.22 → v5.0.52026-04-12

v4.5.7 → v5.0.62026-04-12

v4.5.10 → v5.1.42026-04-20

v4.5.11 → v5.0.72026-04-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6410303?v=4)[Michael Douglas Meneses de Souza](/maintainers/michaelmeneses)[@michaelmeneses](https://github.com/michaelmeneses)

---

Top Contributors

[![michaelmeneses](https://avatars.githubusercontent.com/u/6410303?v=4)](https://github.com/michaelmeneses "michaelmeneses (17 commits)")

---

Tags

PHPStanautocompleteidestatic analysisstubsmoodlepsalm

### Embed Badge

![Health badge](/badges/michaelmeneses-moodle-stubs/health.svg)

```
[![Health](https://phpackages.com/badges/michaelmeneses-moodle-stubs/health.svg)](https://phpackages.com/packages/michaelmeneses-moodle-stubs)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k129.4M822](/packages/barryvdh-laravel-ide-helper)[jetbrains/phpstorm-stubs

PHP runtime &amp; extensions header files for PhpStorm

1.4k30.9M79](/packages/jetbrains-phpstorm-stubs)[phalcon/ide-stubs

The most complete Phalcon Framework IDE stubs library which enables autocompletion in modern IDEs.

1693.2M128](/packages/phalcon-ide-stubs)[php-stubs/wordpress-stubs

WordPress function and class declaration stubs for static analysis.

19915.0M370](/packages/php-stubs-wordpress-stubs)[php-stubs/woocommerce-stubs

WooCommerce function and class declaration stubs for static analysis.

953.3M90](/packages/php-stubs-woocommerce-stubs)[php-stubs/wp-cli-stubs

WP-CLI function and class declaration stubs for static analysis.

302.7M117](/packages/php-stubs-wp-cli-stubs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
