- Installing plugins
- Creating custom plugins
- Publishing your plugin
You can easily add your own commands that are specific to your workflow. You can install plugins by a third party or make your own. In this document we’ll explain you how.
We have created a separate example plugin that adds a backup command to the console tool.
Plugins should be published on Packagist because they will be installed using Composer in the background. You just need to pass their package name. In the case of our example, the package name is
Install with the following command
joomla plugin:install joomlatools/console-backup
You can specify a specific version or branch by appending the version number to the package name. For example:
joomlatools/console-backup:dev-master. Version constraints follow Composer’s convention.
Verify that the plugin is available:
You can now create a backup of a site by running the following command:
joomla site:backup sitename
The tarball and mysql dump will be stored in your home directory. You can change this location using the
For all available options, run
joomla help site:backup
To remove a plugin, run the uninstall command:
joomla plugin:uninstall joomlatools/console-backup
Creating custom plugins
Implementing a new command
Commands should always go into the
Foo/Console/Command directory, where
Foo is your name or company name. This path must be the same as the namespace of the command class.
- Create the directories
- Create a file Hello.php in that new directory.
- Put in the following PHP code:
The entire tool is build using Symfony’s Console package. Commands subclass their
Command class. You can find complete instructions on how to build a symfony console command with extra arguments and options on their documentation pages.
Take a look at the source of our backup plugin for a working example.
Registering custom symlinkers
The extension:symlink symlinks projects into a site to make ease development. Sometimes you might need more steps before symlinking can work (for example, creating new directories) or you might need to pull in extra dependencies. That’s why it is possible to register custom symlinkers and dependencies.
To define extra dependencies for a given symlink:
If you now symlink
joomla extension:symlink site com_foobar, the defined dependencies will automatically be symlinked too.
You can pass a function to
Extension\Symlink::registerSymlinker to add new behavior to the symlink command.
If the function returns true, the symlinker will not run the default symlinking logic afterwards.
Publishing your plugin
To make your plugin installable, you need to add a Composer manifest. Create a file
composer.json in the root directory of this plugin with the following information:
A quick explanation of these fields:
- Name is required and must adhere to the Composer convention, eg
- Description is required for publishing packages
- Type must be set
joomlatools-console-plugin, otherwise it will not be installed
- You must tell Composer how to map the namespace to your classes. Otherwise joomlatools-console will fail to recognize it. If you are only including a symlinker file, autoloading the file will be sufficient.
To find out all available options and get more information on these fields, please refer to the composer.json schema documentation.
Now push your files to a GitHub repository and publish it on Packagist!
Once published on Packagist, you’ll be able install it by running the install command:
joomla plugin:install foo/bar where
foo/bar is the name you defined in composer.json!
Let our developers personally assist you. You can ask development related questions in our Support Center. Only for Business or Agency subscribers.