Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Plugin skeleton generator.

Plugin skeleton generator

From MoodleDocs
Revision as of 08:03, 21 August 2016 by Alexandru Elisei (talk | contribs) (Add web interface help)

Generate plugin skeleton

The plugin will generate the skeleton files needed for a specific plugin type. The full functionality of the plugin can be accessed either via a web interface or the command line script.

To generate a skeleton plugin via the web interface:

  1. Proceed to Administration > Site administration > Development > Generate plugin skeleton
  2. Fill in the various plugin features then click on the "Download plugin skeleton button"
Generate plugin skeleton

To generate the plugin skeleton by using the comand line interface:

  1. Create a recipe file in the YAML format, either by writing it from scratch or by editing the template recipe located at "cli/example.yaml" (recommended)
  2. Invoke the command line script at "cli/generate.php":
   php cli/generate.php --recipe=recipe.yaml

Installation

This plugin has been tested to work with Moodle 3.1 and newer. There are no guarantess it will work with earlier versions.

General installation procedures are those common for all Moodle plugins: Installing plugins.

When downloading the plugin from the git repository tool_pluginskel there are several options available: cloning the repository, downloading the zip file and extracting it or using the zip file for the plugin install interface accessible at Administration > Site administration > Plugins > Install plugins.

If you choose to clone the repository, then you need to clone it into MOODLE_ROOT_DIRECTORY/admin/tool/pluginskel:

   git clone https://github.com/mudrd8mz/moodle-tool_pluginskel MOODLE_ROOT_DIRECTORY/admin/tool/pluginskel

replacing MOODLE_ROOT_DIRECTORY with the actual Moodle installation root directory path. The zip file should be extracted to the same location.

Keep in mind that cloning the repository also creates a hidden .git directory, which you may not want on live servers.

Note: If you decide to use the install plugin interface don't forget to rename the folder inside the archive to pluginskel.


The web interface

The web interface is accessible from Administration > Site administration > Development > Generate plugin skeleton. You are given a choice between filling in all the required fields manually, uploading a previously created recipe file or writing the recipe by hand in the text area (presumably by copying and pasting an existing recipe).

The second page of the web interface presents you with all the options needed to generate the complete plugin skeleton. There are help icons associated with each element, as well as links to the relevant Moodle documentation, to guide you through the creation process.

Plugin skeleton creation

After you have filled the necessary fields, you are given three options:

  1. You can generate the plugin files and download them by clicking on the Download plugin skeleton button. The files will be packaged as a zip archive.
  2. You can choose to generate and save a recipe file in the YAML format from the form input. This is accomplished by clicking on the Download recipe button.
  3. You can view and edit the recipe created from the form by clicking the Show recipe button. You will be taken to the edit recipe web page:
View and edit the recipe

It's worth noting that any changes you make here to the recipe will be reflected on the previous page if you click the Back button.