0

Hello my joomla extension is done with a package whith contains the compenent, the library, the plugins, the medias. I have an auto-uninstall feature into my component, but when use it at the end Joomla! said that the package is still here . That's is the code that i use in a controller of my component :

$installer = new MyExtensionModelInstall;
$installer->uninstall();
$installer->deleteTables('myextension_');

$installer = new \Joomla\CMS\Installer\Installer;
$component = ComponentHelper::getComponent('com_myextension');
$installer->uninstall('component', $component->id);

if (File::exists(JPATH_ADMINISTRATOR . '/manifests/packages/pkg_myextension.xml'))
{
    File::delete(JPATH_ADMINISTRATOR . '/manifests/packages/pkg_myextension.xml');
}

$this->setRedirect('index.php?option=com_installer');

So, how to uninstall too the extension package ?

Thanks by advance

1 Answer 1

1

In your pkg_myextension.xml you need to declare, as a minimum, an <uninstall> SQL file to remove the associated data from the Joomla database. It could be something as simple as below, depending on your database structure.

DROP TABLE IF EXISTS `#__yourcomponent_table1`;
DROP TABLE IF EXISTS `#__yourcomponent_table2`;

DELETE FROM `#__content_types` WHERE (type_alias LIKE 'com_yourcomponent.%');

You probably ought to review the docs here too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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