Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

version.php

From MoodleDocs
Revision as of 12:37, 9 December 2011 by David Smith 2 (talk | contribs) (Added Moodle 2.2 version number)

This file is included in the main directory of plugin. It is compulsory for most plugin types. Even when not compulsory it is highly recommended.

It contains a number of fields, which are used during the install / upgrade process to make sure the plugin is compatible with the current Moodle install, as well as spotting whether an upgrade is needed.

The file is a standard PHP file, starting with an opening '<?php' tag and defining the following variables:

Note! For Activity modules replace $plugin-> with $module-> in the following example!

  • $plugin->version = 2011051000;
    • Required - the version number of your plugin in the form YYYYMMDDxx, so this example is 10th May 2011 (with 00 indicating this is the first version for that day)
  • $plugin->requires = 2010112400;
    • Optional - minimum version number of Moodle that this plugin requires (Moodle 1.9 = 2007101509; Moodle 2.0 = 2010112400; Moodle 2.1 = 2011070100; Moodle 2.2 = 2011120100)
  • $plugin->cron = 0;
    • Optional - time interval (in seconds) between calls to the plugin's 'cron' function; set to 0 to disable the cron function calls.
    • Cron support is not yet implemented for all plugins.
  • $plugin->component = 'plugintype_pluginname';
    • Optional - frankenstyle plugin name, strongly recommended. It is used for installation and upgrade diagnostics.
  • $plugin->maturity = MATURITY_STABLE;
    • Optional - how stable the plugin is: MATURITY_ALPHA, MATURITY_BETA, MATURITY_RC, MATURITY_STABLE (Moodle 2.0 and above)
  • $plugin->release = '2.x (Build: 2011051000)';
    • Optional - Human-readable version name
  • $plugin->dependencies = array ('mod_forum' => ANY_VERSION, 'mod_data' => 2010020300);
    • Optional - list of other plugins that are required for this plugin to work (Moodle 2.2 and above)
    • In this example, the plugin requires any version of the forum activity and version '20100020300' (or above) of the database activity