Note:

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

Plugin files: Difference between revisions

From MoodleDocs
m (Mudrd8mz moved page Things that work the same in all plugin types to Plugin files: Shorten URL)
mNo edit summary
Line 1: Line 1:
{{Plugins development}}
{{stub}}
{{stub}}


There are some files that work the same in all plugin types (if they are present). We document them here.
There are some files that work the same in all [[Plugin types|plugin types]] (if they are present).


; '''[[version.php]]'''
=== version.php ===
: give metadata about the plugin, like the version number.
; '''lang/en/plugintype_pluginname.php'''
: strings for your plugin, at least 'pluginname' must be present
; '''db/'''
: this folder contains information that is used to install the plugin.
:; '''install.xml'''
:; '''upgrade.php'''
:; '''install.php'''
:: These three files are to do with [[Upgrade_API|creating the and updating the database tables required by your plugin]].
:; '''access.php'''
:: This is where you define any [[Access_API|capabilities]] that your plugin uses.
:; ...
:: There are lots of other things that can go in the db folder, but I don't have time to describe them now.
; '''classes/'''
: This folder contains the definition of any classes for your plugin that you want the auto-loader to be able to find. You can define any classes you like at the top level.
:; ''[core  API name]''
:: within classes/, the top level folders are reserved for the names of [[Core APIs]] except for
:; '''local/'''
:: You can put whatever you like within the local namespace, including as many nested namespaces as you like.
:; '''question/bank/'''
:: This is where you define new question bank column types. See mod_quiz as an example.


[[Category:Plugins]]
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
 
=== lang/en/plugintype_pluginname.php ===
 
English strings for the plugin are defined here. At least <tt>$string['pluginname']</tt> must be present. There is an exception for the [[Activity modules]], their expected file name is just <tt>pluginname.php</tt> (without the <tt>mod_</tt> prefix).
 
* [[String API]] provides information about the string files
 
=== lib.php ===
 
=== db/install.xml ===
 
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.
 
* [[XMLDB Documentation]]
 
=== db/upgrade.php ===
 
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.
 
* [[Upgrade API]]
 
=== db/access.php ===
 
Plugin capabilities are defined here.
 
* [[Access_API]]
 
=== classes ===
 
* [[Automatic class loading]]
* [[Coding style#Namespaces]]

Revision as of 08:46, 30 April 2015



There are some files that work the same in all plugin types (if they are present).

version.php

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

lang/en/plugintype_pluginname.php

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

lib.php

db/install.xml

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.

db/upgrade.php

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.

db/access.php

Plugin capabilities are defined here.

classes