How could you do programmatically what Joomla does when you install a plugin? Let's say, for simplicity's sake, that you have a plugin package file local with your Joomla instance.

A solution might look like one of:

  • a) You make a POST request to a Joomla endpoint with the package file that installs the plugin.

  • b) You write a shell script that both installs the package file's contents in the correct folder, and writes the required data to the db (more brittle this way).


Use Install model.

if (!defined('_JEXEC'))
    define('_JEXEC', 1);
    define('JPATH_BASE', realpath(__DIR__));
    require_once JPATH_BASE . '/includes/defines.php';
    require_once JPATH_BASE . '/includes/framework.php';

JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_installer/models', 'InstallerModel');
$input = JFactory::getApplication('site')->input;
$input->set('installtype', 'folder');
$input->set('install_directory', $path);
$model = JModelLegacy::getInstance('Install', 'InstallerModel', array('ignore_request' => true));

Where $path is path to extension installation files.

  • Thanks for this. This would work once I have access to the Joomla runtime. Do you know of any way this could be done externally, without access to that runtime?
    – steel
    Jul 26 '18 at 13:24
  • If you need to run this in external script, add Joomla dependencies and define the application in JFactory::getApplication() call. I have updated the answer to reflect this. You may also look into making a CLI application.
    – Sharky
    Jul 27 '18 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.