How to execute advanced tasks on extension install
Joomla’s database update management is advanced, but sometimes, it’s not enough for our needs and we need to perform custom checks and tasks when installing our extensions.
We can specify a PHP script to perform custom tasks when installing our extensions. As a good example, let’s add a PHP check to our install
extension and enable our plugins automatically after installing them.
To do this, edit the src/component/spm.xml
component manifest file and add the <scriptfile>
tag to the following section:
<extension> ... <scriptfile>script.php</scriptfile> ... </extension>
With that, we’ve instructed Joomla! to look for the script.php
file in the main folder of our package and execute the instructions it finds there.
Next, create the src/component/script.php
file with the following content:
<?php defined('_JEXEC') or die; class Com_SpmInstallerScript...