Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How does onExtensionAfterUninstall differ from onExtensionBeforeInstall
    Joomla Events


How does onExtensionAfterUninstall differ from onExtensionBeforeInstall


The `onExtensionAfterUninstall` and `onExtensionBeforeInstall` events in Joomla differ in the following ways:

onExtensionAfterUninstall

- Triggered after an extension is uninstalled in Joomla
- Allows you to perform additional processing or cleanup when an extension is uninstalled
- Can be used to find and remove associated packages or data related to the uninstalled extension[1][2]

For example, this code snippet finds and removes a package associated with the uninstalled extension:

php
$package_id = $extension->find(array('type' => 'package', 'element' => 'pkg_jce'));
if ($package_id) {
    $plg_extension_joomla->onExtensionAfterUninstall($installer, $package_id, true);
}

onExtensionBeforeInstall

- Triggered before an extension is installed in Joomla
- Allows you to perform checks or preparations before the extension is installed
- Can be used to validate requirements or settings before proceeding with the installation[1][2]

The key differences are:

- `onExtensionAfterUninstall` fires after uninstallation, while `onExtensionBeforeInstall` fires before installation
- `onExtensionAfterUninstall` is used for cleanup and removing associated data, while `onExtensionBeforeInstall` is used for validation and preparation

Both events provide hooks for extensions to interact with the installation process, but at different stages and for different purposes. The search results provide examples of how each event can be used in a Joomla plugin.

Citations:
[1] https://fliphtml5.com/eztvv/yypz/Learning_Joomla_3_Extensions_Development/
[2] https://library.iimk.ac.in/pdfs/ebooks/4/9781782168386.pdf
[3] https://community.onestreamsoftware.com/t5/Application-Build/Extensibility-comparison/td-p/13550
[4] https://www.joomlatools.com/extensions/logman/developer/plugins/joomla-framework
[5] https://docs.joomla.org/J2.5:What%27s_new_in_Joomla_2.5