Extensions Management Utility
To manage extensions from the command line, you can use the
extension
command line utility. 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
plesk bin extension <command> [<param>][<option_1> [<param>]][<option_2>]
Read about all commands and options that can be used by the utility in the CLI Guide for Linux or for Windows.
Below are the examples of the actions you can perform with an extension
using the extension
utility.
Installing an Extension
Installation of an extension involves the following:
- Extracting data from the archive.
- Execution of the pre-install script.
- Copying the parts of the extension to the specified directories.
- Registration of the extension in the database.
- 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:
- Execution of the pre-uninstall script.
- Removal of information from the database (from the list of registered extensions).
- 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:
- Execution of the pre-install script.
- Registration of the extension in the database.
- 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