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.
extension command [options]
Command |
Parameter |
Description |
|
|
Creates an extension template. Based on the template, you can develop a new extension. Is used with the |
|
|
Registers a specified extension. |
|
|
Installs an extension from a .zip file. |
|
|
Removes a specified extension from Plesk. |
|
|
Exports a specified extension to a .zip file for further distribution. Is used with the |
|
|
Displays a list of installed extensions. |
|
|
Displays a help page. |
Option |
Parameter |
Description |
|
|
A path to the directory where the exported extension should be located. |
|
|
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. |
|
|
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. |
Installation of an extension involves the following:
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.
Removal of an extension involves the following:
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.
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/
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:
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.
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
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