12

How to uninstall module ?

I read this document

But it was not successful, and display below:

php bin/magento module:uninstall SP_Gridthumbs 

SP_Gridthumbs is not an installed composer package

44

it says in the documentation you linked, this:

This command works only with modules defined as Composer packages.

If you did not install the module via composer, it won't work.
You can only disable it via bin/magento module:disable SP_Gridthumbs.

To remove the module, remove the folder SP/Gridthumbs, remove the record with module = 'SP_Gridthumbs' from the table setup_module and remove any other tables or records added by the install of the module.
Also remove the line with SP_Gridthumbs from app/etc/config.php

| improve this answer | |
  • How to remove all this module out of project, your way just disable. – MrTo-Kane Mar 8 '16 at 10:03
  • @MagentoOdoo.com see my update – Marius Mar 8 '16 at 10:12
  • You should also clean the cache – WaPoNe Feb 1 '17 at 13:53
  • 3
    I tested it. Remove the line with SP_Gridthumbs from app/etc/config.php doesn't need. Magento will auto remove the record by run php bin/magento setup:upgrade – Key Shang Nov 10 '17 at 9:01
  • Actually I have to update one record from table and this code put in InstallData.php::install() and when enable module and setup:upgrade it run my code. and now i need when i disable the module then should also remove recorde from table i did code in Uninstall::uninstall but not trigger when disable module. Which file trigger when disable the module and setup:upgrade – HaFiz Umer Nov 4 '19 at 6:52
10

Below are the steps to Uninstall Module Manually for Magento 2

  • Delete the Module folder from {folder path}\app\code

  • Remove module entry from setup_module

  • Run command

    {magento project root path}>{php path}\php.exe bin/magento setup:upgrade => Setup Upgrade

    {magento project root path}>{php path}\php.exe bin/magento cache:flush => Clear Cache

| improve this answer | |
4

How about:

php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-content
composer remove VendorName/VendorExtensionRepository
php bin/magento setup:upgrade

For composer modules:

php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-content
php bin/magento module:uninstall <ExtensionProvider_ExtensionName> -r
composer update
php bin/magento setup:upgrade
| improve this answer | |
  • Running setup: upgrade while there are modules that were not installed via composer will get them being installed and enabled again which defeats the purpose. – Mohammed Joraid Jul 10 '18 at 5:44
  • 1
    @MohammedJoraid see updated answer – Arvind07 Jul 25 '18 at 6:32
2

Steps to uninstall a composer installed module

  • bin/magento module:disable Namespace_ModuleName
  • bin/magento module:uninstall Namespace_ModuleName
  • composer remove namespace/module-name
  • bin/magento cache:flush

Steps to uninstall a manually added module in app/code

  • bin/magento module:disable Namespace_ModuleName
  • remove directory from app/code manually
  • bin/magento setup:upgrade
  • bin/magento cache:flush
| improve this answer | |
1

HERE IS THE STEP BY STEP GUIDE TO UNINSTALL ANY THIRD PARTY MODULE FROM MAGENTO 2 MANUALLY.

Step 1: Remove the module Vendor_Mymodule from app\etc\config.php

Step 2: Drop module tables or columns from database, please check app\code\Vendor\Module\Setup folder for more information

Step 3: Remove the folder app\code\vendor\Mymodule

Step 4: Remove module configuration settings from core_config_data table by running the following query


 DELETE FROM setup_module WHERE module LIKE 'vendor_Mymodule';
Step 5: Run the following command by logging onto your SSH server

 php bin/magento setup:upgrade
But if you have installed the module via composer then you can run the following list of commands by SSHing on the box to uninstall third party module

 php bin/magento module:uninstall -r {{module_name}}
for example

php bin/magento module:uninstall -r Scommerce_GoogleTagManagerPro
-r flag removes module data 

Run the following command once module has been successfully uninstalled.

 php bin/magento setup:upgrade

To Custom Magento2 Module

step1: disable the module 
$php bin/magento module:disable Vendor_MyModule
step2: remove the folder from directory app/code/Vendor
step3: remove the line of code from app/etc/config.php file.

for more on uninstalling 3rd party/composer installed extensions

https://www.scommerce-mage.com/blog/magento2-uninstall-module.html

| improve this answer | |
  • What if you've got different modules by the same vendor you want to keep? Your SQL queries will break these. – Dominic Xigen Oct 23 '19 at 7:44
  • Just edited my Answer. – Arshad Syed Oct 23 '19 at 9:08
0

I think it's wise to first disable the module using

php bin/magento module:disable modulename

because this checks for dependencies...

| improve this answer | |
0

Uninstall extension from magento 2:

  1. Go to your magento project directory in CLI and check for module status, by running command php bin/magento module:status

  2. If it is enable make it disable by running command php bin/magento module:disable <extension name>

  3. Go to database and search for 'setup_module' table and search for your extension name and delete it

  4. Delete the your extension name folder from app/code folder

  5. Run the setup:upgrade command.

  6. You have succesfulley uninstalled the extension.

| improve this answer | |
0

Magento 2: How to uninstall module

1. If you installed it manually:

remove the folder app/code/<Vendor>/<Module>
drop module tables from database
remove the config settings.

DELETE FROM core_config_data WHERE path LIKE 'vendor_module/%'   
DELETE FROM core_config_data WHERE path LIKE 'vendor_module/%'

remove the module <Vendor>_<Module> from app/etc/config.php

remove the module <Vendor>_<Module> from table setup_module

DELETE FROM setup_module WHERE module='<Vendor>_<Module>'    
DELETE FROM setup_module WHERE module='<Vendor>_<Module>'

2.If you installed it via composer:

run this in console
php bin/magento module:status
php bin/magento module:disable mirasvit/module-core --clear-static-content
php bin/magento module:uninstall -r <Vendor>_<Module>    
php bin/magento setup:upgrade
php bin/magento c:f
composer remove mirasvit/module-core

Hope Someone get help

| improve this answer | |
  • 1
    I just created module without using composer.json file after the day i installed composer.json is it possible to uninstalled the module using composer? my module => github.com/ZusZus/simple-module/tree/master/app/code/Gta/Mymod @matinict – zus Feb 29 at 5:44
  • @zus to avoid conflict first you need to remove code from app/code , yes i think u can install/uninstall via composer, (ur module link may be not work composer install u need to add your repo packagist.org ) – matinict Feb 29 at 14:03
-7
  1. Open setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php

and replace

protected function validate(array $modules)
{
    $messages = [];
    $unknownPackages = [];
    $unknownModules = [];
    $installedPackages = $this->composer->getRootRequiredPackages();
    foreach ($modules as $module) {
        if (array_search($this->packageInfo->getPackageName($module), $installedPackages) === false) {
            $unknownPackages[] = $module;
        }
        if (!$this->fullModuleList->has($module)) {
            $unknownModules[] = $module;
        }
    }
    $unknownPackages = array_diff($unknownPackages, $unknownModules);
    if (!empty($unknownPackages)) {
        $text = count($unknownPackages) > 1 ?
            ' are not installed composer packages' : ' is not an installed composer package';
        $messages[] = '<error>' . implode(', ', $unknownPackages) . $text . '</error>';
    }
    if (!empty($unknownModules)) {
        $messages[] = '<error>Unknown module(s): ' . implode(', ', $unknownModules) . '</error>';
    }
    return $messages;
}

with

protected function validate(array $modules)
{
    $messages = [];
    $unknownPackages = [];
    $unknownModules = [];
    $installedPackages = $this->composer->getRootRequiredPackages();
    foreach ($modules as $module) {
        if (array_search($this->packageInfo->getPackageName($module), $installedPackages) === false) {
            $unknownPackages[] = $module;
        }
        if (!$this->fullModuleList->has($module)) {
            $unknownModules[] = $module;
        }
    }
    if (!empty($unknownModules)) {
        $messages[] = '<error>Unknown module(s): ' . implode(', ', $unknownModules) . '</error>';
    }
    return $messages;
}
  1. Open setup/src/Magento/Setup/Model/ModuleUninstaller.php

and replace

public function uninstallCode(OutputInterface $output, array $modules)
{
    $output->writeln('<info>Removing code from Magento codebase:</info>');
    $packages = [];
    /** @var \Magento\Framework\Module\PackageInfo $packageInfo */
    $packageInfo = $this->objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create();
    foreach ($modules as $module) {
        $packages[] = $packageInfo->getPackageName($module);
    }
    $this->remove->remove($packages);
}

with

public function uninstallCode(OutputInterface $output, array $modules)
{
    $output->writeln('<info>Removing code from Magento codebase:</info>');
    $packages = [];
    /** @var \Magento\Framework\Module\PackageInfo $packageInfo */
    $packageInfo = $this->objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create();
    foreach ($modules as $module) {
        $packages[] = $packageInfo->getPackageName($module);
    }
}
  1. Say "lyaska masyaska"

Note, the solution isn't recommended on production server

| improve this answer | |

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.