PHPackages                             moodlehq/moodle-cs - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. moodlehq/moodle-cs

ActivePhpcodesniffer-standard[Testing &amp; Quality](/categories/testing)

moodlehq/moodle-cs
==================

Moodle Coding Sniffer rules

v3.7.0(5mo ago)242.8M—8.4%17[46 issues](https://github.com/moodlehq/moodle-cs/issues)[8 PRs](https://github.com/moodlehq/moodle-cs/pulls)5GPL-2.0-or-laterPHPPHP &gt;=7.4.0CI passing

Since Feb 28Pushed 5mo ago19 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (41)Used By (5)

Moodle Coding Style
===================

[](#moodle-coding-style)

[![Latest Stable Version](https://camo.githubusercontent.com/5d3f409ba2c0aa3f84a1759d633c6595cecb6d8e56d458f4c6c020a52389f892/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f646c6568712f6d6f6f646c652d63732f762f737461626c65)](https://packagist.org/packages/moodlehq/moodle-cs)[![Release Date of the Latest Version](https://camo.githubusercontent.com/5e5418b5bf050a6c4ed3e1df2eab8b7524c2e4f2902168425681755525d0b68f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f6d6f6f646c6568712f6d6f6f646c652d63732e7376673f6d61784167653d31383030)](https://github.com/moodlehq/moodle-cs/releases)

[![Unit Tests](https://github.com/moodlehq/moodle-cs/actions/workflows/phpcs.yml/badge.svg)](https://github.com/moodlehq/moodle-cs/actions/workflows/phpcs.yml)[![codecov](https://camo.githubusercontent.com/84a3abfe5bb007c2e6d3f76260c8a6ef5dafd429d7d721523d410957cf51eb74/68747470733a2f2f636f6465636f762e696f2f67682f6d6f6f646c6568712f6d6f6f646c652d63732f67726170682f62616467652e7376673f746f6b656e3d5a344939353549553048)](https://codecov.io/gh/moodlehq/moodle-cs)

[![License](https://camo.githubusercontent.com/9484dff73a171fc9c5c7b40e8976c7d2219a400273b9d51e8747cd076b518f94/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f646c6568712f6d6f6f646c652d63732f6c6963656e7365)](https://github.com/moodlehq/moodle-cs/blob/main/LICENSE)[![Total Downloads](https://camo.githubusercontent.com/0c6d0a5b9f0fbff09633c7fb1ae03c8cb7039d40f3d9766c22f851f3882eba42/68747470733a2f2f706f7365722e707567782e6f72672f6d6f6f646c6568712f6d6f6f646c652d63732f646f776e6c6f616473)](https://packagist.org/packages/moodlehq/moodle-cs/stats)[![Number of Contributors](https://camo.githubusercontent.com/fdfc08b59c60ec6b668a3e62633001f80dd2fbe5c9166708c56088973b8a63a2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6d6f6f646c6568712f6d6f6f646c652d63732e7376673f6d61784167653d33363030)](https://github.com/moodlehq/moodle-cs/graphs/contributors)

Information
-----------

[](#information)

This repository contains the Moodle Coding Style configurations, written as [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) rulesets.

Two coding styles are included:

- `moodle` - the main ruleset for the [Moodle Coding Style](https://moodledev.io/general/development/policies/codingstyle)
- `moodle-extra` - extended ruleset which includes recommended best practices
    - extends the main `moodle` ruleset

Currently this only includes the configuration for PHP Coding style, but this may be extended to include custom rules for JavaScript, and any other supported languages or syntaxes.

Installation
------------

[](#installation)

### Using Composer (recommended)

[](#using-composer-recommended)

You can install these coding style rules using Composer to make them available globally across your system.

This will install the correct version of phpcs, with the Moodle rules, and their dependencies.

```
composer global config minimum-stability dev
composer global require moodlehq/moodle-cs
```

Configuration
-------------

[](#configuration)

Typically configuration is not required. Recent versions of Moodle (3.11 onwards) include a configuration file for the PHP CodeSniffer, which will set the standard when run within a Moodle directory.

Additional configuration can be generated automatically to have PHP CodeSniffer ignore any third-party library code. This can be generated by running:

```
npx grunt ignorefiles
```

### Using the `moodle-extra` coding style

[](#using-the-moodle-extra-coding-style)

The recommended way of configuring PHP CodeSniffer to use the `moodle-extra` coding style is to provide an additional configuration file.

For Moodle 3.11 onwards you can create a file named `.phpcs.xml` with the following contents:

```

```

This will load the `phpcs.xml` file (generated by `npx grunt ignorefiles`), and apply the `moodle-extra` configuration on top.

### Moodle 3.10 and earlier

[](#moodle-310-and-earlier)

The easiset way to have PHP CodeSniffer pick up your preferred style, you can create a file named `phpcs.xml` with the following contents:

```

```

If you wish to use the `moodle-extra` coding style, then you can use the following content:

```

```

Note: Third-party library code will not be ignored with these versions of Moodle.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance50

Moderate activity, may be stable

Popularity54

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 54.3% 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 ~35 days

Total

40

Last Release

168d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af50aff7bc9a1b0863806f0a384ce233451b87a1425b4b4de51aea64810ace59?d=identicon)[andrewnicols](/maintainers/andrewnicols)

![](https://www.gravatar.com/avatar/8aa132a6b5f982e20f7d7b00cd7255671b228e77ccbf29a24b66eb42353b9d96?d=identicon)[stronk7](/maintainers/stronk7)

---

Top Contributors

[![stronk7](https://avatars.githubusercontent.com/u/167147?v=4)](https://github.com/stronk7 "stronk7 (261 commits)")[![andrewnicols](https://avatars.githubusercontent.com/u/370047?v=4)](https://github.com/andrewnicols "andrewnicols (134 commits)")[![timhunt](https://avatars.githubusercontent.com/u/138653?v=4)](https://github.com/timhunt "timhunt (16 commits)")[![danpoltawski](https://avatars.githubusercontent.com/u/533249?v=4)](https://github.com/danpoltawski "danpoltawski (12 commits)")[![junpataleta](https://avatars.githubusercontent.com/u/13312075?v=4)](https://github.com/junpataleta "junpataleta (12 commits)")[![sarjona](https://avatars.githubusercontent.com/u/900389?v=4)](https://github.com/sarjona "sarjona (9 commits)")[![paulholden](https://avatars.githubusercontent.com/u/1126541?v=4)](https://github.com/paulholden "paulholden (5 commits)")[![cameron1729](https://avatars.githubusercontent.com/u/89116254?v=4)](https://github.com/cameron1729 "cameron1729 (4 commits)")[![kabalin](https://avatars.githubusercontent.com/u/329780?v=4)](https://github.com/kabalin "kabalin (4 commits)")[![micaherne](https://avatars.githubusercontent.com/u/516366?v=4)](https://github.com/micaherne "micaherne (3 commits)")[![ankitagarwal](https://avatars.githubusercontent.com/u/596844?v=4)](https://github.com/ankitagarwal "ankitagarwal (3 commits)")[![jrchamp](https://avatars.githubusercontent.com/u/625298?v=4)](https://github.com/jrchamp "jrchamp (3 commits)")[![mudrd8mz](https://avatars.githubusercontent.com/u/85831?v=4)](https://github.com/mudrd8mz "mudrd8mz (2 commits)")[![polothy](https://avatars.githubusercontent.com/u/634657?v=4)](https://github.com/polothy "polothy (2 commits)")[![lameze](https://avatars.githubusercontent.com/u/6903296?v=4)](https://github.com/lameze "lameze (2 commits)")[![roperto](https://avatars.githubusercontent.com/u/3672494?v=4)](https://github.com/roperto "roperto (1 commits)")[![sammarshallou](https://avatars.githubusercontent.com/u/68663?v=4)](https://github.com/sammarshallou "sammarshallou (1 commits)")[![golenkovm](https://avatars.githubusercontent.com/u/22066290?v=4)](https://github.com/golenkovm "golenkovm (1 commits)")[![garemoko](https://avatars.githubusercontent.com/u/1363163?v=4)](https://github.com/garemoko "garemoko (1 commits)")[![brendanheywood](https://avatars.githubusercontent.com/u/187449?v=4)](https://github.com/brendanheywood "brendanheywood (1 commits)")

---

Tags

codingstandardscodingstylephpcodesniffer-standardstylephpcsstylemoodlestandardcodesniffercodingsniff

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/moodlehq-moodle-cs/health.svg)

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

###  Alternatives

[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

598161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[slevomat/coding-standard

Slevomat Coding Standard for PHP\_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.

1.5k123.5M1.8k](/packages/slevomat-coding-standard)[consistence/coding-standard

Consistence - Coding Standard - PHP Code Sniffer rules

75833.3k94](/packages/consistence-coding-standard)[doctrine/coding-standard

The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.

31914.1M739](/packages/doctrine-coding-standard)[phpmyadmin/coding-standard

phpMyAdmin PHP\_CodeSniffer Coding Standard

201.2M7](/packages/phpmyadmin-coding-standard)

PHPackages © 2026

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