Extensions Management Utility

To manage extensions from the command line, you can use a new utility called extensions. It is located in the directory %plesk-root%/bin. The utility provides the following functions: Installing new extensions, removing existing extensions, packing the source files of an extension into a ZIP archive ready for distribution, generating an extension template.

Usage

extension command [options]

Commands
Command Parameter Description

--create or -c

<name>

Creates an extension template. Based on the template, you can develop a new extension.

Is used with the -no-ui and -no-scripts options.

--register or -r

<name>

Registers a specified extension.

--install or -i

<file>

Installs an extension from a .zip file.

--uninstall or -u

<name>

Removes a specified extension from Plesk.

--pack or -p

<name>

Exports a specified extension to a .zip file for further distribution.

Is used with the -destination option.

--list or -l

 

Displays a list of installed extensions.

--help or -h

 

Displays a help page.

Options
Option Parameter Description

-destination

<path>

A path to the directory where the exported extension should be located.

-no-ui

 

Do not add resource files defined by an extension template to a created extension. The new extension will contain a meta file and installation scripts only.

-no-scripts

 

Do not add installation scripts defined by an extension template to a created extension. The new extension will contain a meta file and resource files only.

Installing an Extension

Installation of an extension involves the following:

  1. Extracting data from the archive.
  2. Execution of the pre-install script.
  3. Copying the parts of the extension to the specified directories.
  4. Registration of the extension in the database.
  5. Execution of the post-install script.

The following is an example of a command for installing an extension:

plesk bin extension -i my-extension.zip

The extension was successfully installed.

You can also install an extension via the Plesk user interface.

Removing an Extension

Removal of an extension involves the following:

  1. Execution of the pre-uninstall script.
  2. Removal of information from the database (from the list of registered extensions).
  3. Removal of the extension's files.

The following is an example of a command for removing an installed extension (an extension ID should be specified as a parameter):

plesk bin extension -u my-extension

The extension was successfully uninstalled.

You can also remove an extension via the Plesk user interface.

Creating a Template for a New Extension

To start developing a new extension, it is very handy to generate an extension template and start building around it.

The following is an example of a command for generating an extension template (an extension ID should be specified as a parameter):

plesk bin extension -c test-module

The extension was successfully created.

The path to extension entry points: /usr/local/psa/admin/htdocs/modules/test-module/

The path to PHP classes: /usr/local/psa/admin/plib/modules/test-module/

The path to installation scripts: /usr/local/psa/admin/plib/modules/test-module/scripts/

The path to the directory with run-time data: /usr/local/psa/var/modules/test-module/

Parts of the extension will be placed in the following directories (relative to the %plesk-root% directory):

  • admin/htdocs/modules/test-module/ - extension entry points, graphics, CSS styles, JavaScript files.
  • admin/plib/modules/test-module/ - PHP classes that implement the extension's logic.
  • var/modules/test-module/ - a directory for storing data that are changed during the run-time, for example, SQLite database, cached data.

If development of the extension does not involve the use of an MVC pattern, you can avoid the creation of additional files by using the -no-ui option.

plesk bin extension -c test-module -no-ui

The extension was successfully created.

The path to installation scripts: /usr/local/psa/admin/plib/modules/test-module/scripts/

The path to the directory with run-time data: /usr/local/psa/var/modules/test-module/

If development of batch scripts is not required, you can avoid the creation of additional files by using the -no-scripts option:

plesk bin extension -c test-module -no-scripts

The extension was successfully created.

The path to module entry points: /usr/local/psa/admin/htdocs/modules/test-module/

The path to PHP classes: /usr/local/psa/admin/plib/modules/test-module/

The path to the directory with run-time data: /usr/local/psa/var/modules/test-module/

Registering an Extension with Plesk

After an extension template is created, it is not considered as installed in Plesk and is not shown in the list of extensions. Registration involves the following:

  1. Execution of the pre-install script.
  2. Registration of the extension in the database.
  3. Execution of the post-install script.

The following is an example of a command for registering an extension (an extension ID should be specified as a parameter):

plesk bin extension -r test-module

The extension was successfully registered.

You can perform registration a number of times, so consider this when implementing your pre-install and post-install scripts.

Preparing a Distribution Package

For your convenience, there is an option to generate a ZIP archive based on an installed extension. To do this, issue the following command:

plesk bin extension -p test-module

The extension was successfully exported to /root/test-module.zip

By default, a ZIP archive is created in the current directory. To create an archive in a specified directory, use the -destination option:

plesk bin extension -p test-module -destination /tmp/

The extension was successfully exported to /tmp/test-module.zip

Viewing a List of Installed Extensions

The utility can show a list of installed extensions with extension names and IDs. This command can be useful, for example, for retrieving the exact ID of an extension for further removal. An example of the command:

plesk bin extension -l

test-module - Extension example