The following is a list of files that work the same in all plugin types (if they are present).
- 1 version.php
- 2 lang/en/plugintype_pluginname.php
- 3 lib.php
- 4 db/install.xml
- 5 db/upgrade.php
- 6 db/access.php
- 7 db/install.php
- 8 db/uninstall.php
- 9 db/events.php
- 10 db/messages.php
- 11 db/services.php
- 12 db/renamedclasses.php
- 13 classes/
- 14 cli/
- 15 settings.php
- 16 amd/
- 17 yui/
- 18 jquery/
- 19 styles.css
- 20 pix/icon.svg
- 21 thirdpartylibs.xml
- 22 readme_moodle.txt
- 23 environment.xml
- 24 README
- 25 CHANGES
- 26 See also
Meta-data about the plugin (like the version number, dependencies or the maturity level) are defined here.
- version.php page provides detailed description of the file contents
English strings for the plugin are defined here. At least $string['pluginname'] must be present. There is an exception for the Activity modules, their expected file name is just pluginname.php (without the mod_ prefix).
- String API provides information about the string files
The interface between the Moodle core and the plugin is defined here for the most plugin types. The expected contents of the file depends on the particular plugin type.
Moodle core often (but not always) loads all the lib.php files of the given plugin types. For the performance reasons, it is strongly recommended to keep this file as small as possible and have just required code implemented in it. All the plugin's internal logic should be implemented in the auto-loaded classes or in the locallib.php file.
The plugin's database scheme (tables, fields, indexes and keys) are defined here. You should always use the in-built XMLDB editor to generate this file.
Upgrade steps (such as database scheme changes and other things that must happen when the plugin is being upgraded) are defined here. The in-built XMLDB editor can be used to generate the code to change the database scheme.
Plugin capabilities are defined here.
Allows you to execute a PHP code right after the plugin's database scheme has been installed.
Allows you to execute a PHP code before the plugin's database tables and data are dropped during the plugin uninstallation.
Event handlers (subscriptions) are defined here. It lists all the events that your plugin want to observe and be notified about.
Allow to declare your plugin as the messaging provider.
External functions and web services provided by your plugin are described here.
Details of classes that have been renamed to fit in with autoloading. See forum discussion for details
It is a convention in the Moodle code that all CLI scripts are put into the cli/ folder inside the plugin directory. Make sure all these files declare themselves as CLI scripts properly (the constant must be defined prior to loading the config.php):
define('CLI_SCRIPT', true); require(__DIR__.'/../../../config.php'); require_once($CFG->libdir.'/clilib.php');
Describes the administration configuration for your plugin.
The setting names are supposed to be plugintype_pluginname/settingname (note the slash) and not plugintype_pluginname_settingname or even just settingname. This makes them to be stored in the config_plugins table without polluting the global $CFG object.
Plugin's jQuery modules (Moodle 2.8 and older)
The plugin's CSS are stored here.
The plugin's icon. Activity modules should provide 24 x 24 px colour icons. All other plugin files should be represented by 16 x 16 px monochrome icon. There should be a fallback pix/icon.png version of the icon for legacy browsers.
- Moodle icons provides icons design guidelines
The file should list all 3rd party libraries bundled with a plugin.
The location is a path to the library directory or file, relative to the plugin's root directory. Please note that license must be always compatible with the GNU GPLv3.
Locations defined in this file are excluded from the coding style prechecks that are executed during the Plugin validation.
More information about 3rd party libraries can be found at: https://docs.moodle.org/dev/Third_Party_Libraries
The file should contain detailed instructions on how to import 3rd party libraries into Moodle. This should list:
- Download URLs
- Build instructions
Plugin can declare its additional environment requirements via this file - such as compulsory presence of some otherwise optional PHP extension. See Environment checking#Configuration file overview for details of the syntax.
<?xml version="1.0" encoding="UTF-8" ?> <COMPATIBILITY_MATRIX> <PLUGIN name="plugintype_pluginname"> <PHP_EXTENSIONS> <PHP_EXTENSION name="soap" level="required"> </PHP_EXTENSION> </PHP_EXTENSIONS> </PLUGIN> </COMPATIBILITY_MATRIX>
The file README.md or README.txt should contain useful information about the plugin. Ideally, it should act as an offline version of all the informations that are available at the plugin's page in the Plugins directory.
If the file CHANGES.md (or CHANGES.txt, CHANGES.html or just CHANGES alternatively) is found when uploading a new plugin version into the Plugins directory, then the contents of this file is used to pre-fill the release notes field for the new version.