Magento 2-如何卸载模块?


Answers:


43

它在您链接的文档中说:

该命令仅适用于定义为Composer软件包的模块。

如果您没有通过composer安装该模块,它将无法正常工作。
您只能通过禁用它bin/magento module:disable SP_Gridthumbs

要删除模块,请删除文件夹SP/Gridthumbs,从表中setup_module删除模块='SP_Gridthumbs'的记录,并删除由模块安装添加的任何其他表或记录。
同时SP_Gridthumbs从中删除行app/etc/config.php


如何从项目中删除所有此模块,只需禁用即可。
MrTo-Kane'3

@ MagentoOdoo.com看到我的更新
Marius

您还应该清理缓存
WaPoNe

3
我测试了 Remove the line with SP_Gridthumbs from app/etc/config.php不需要 Magento将通过运行自动删除记录php bin/magento setup:upgrade
Key Shang

实际上,我必须从表中更新一条记录,并将此代码放入InstallData.php :: install()中,并在启用模块和setup:upgrade时运行我的代码。现在我需要当我禁用模块时,也应该从表中删除recorde,我在Uninstall :: uninstall中执行了代码,但是禁用模块时不触发。禁用模块和设置时哪个文件触发:升级
HaFiz Umer

10

以下是手动卸载Magento 2的模块的步骤

  • 从中删除模块文件夹 {folder path}\app\code
  • 从中删除模块条目 setup_module
  • 运行命令

    {magento项目根路径}> {php路径} \ php.exe bin / magento setup:upgrade =>安装程序升级

    {magento项目根路径}> {php路径} \ php.exe bin / magento缓存:刷新=>清除缓存


4

怎么样:

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

对于作曲家模块:

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

运行安装程序:在有一些未通过composer安装的模块上进行升级时,将重新安装并启用它们,这将无法达到目的。
Mohammed Joraid '18年

1
@MohammedJoraid查看最新答案
Arvind07年

1

卸载Composer已安装模块的步骤

  • bin / magento模块:禁用Namespace_ModuleName
  • bin / magento模块:卸载Namespace_ModuleName
  • 作曲家删除名称空间/模块名称
  • bin / magento缓存:刷新

卸载应用程序/代码中手动添加的模块的步骤

  • bin / magento模块:禁用Namespace_ModuleName
  • 从应用程序/代码中手动删除目录
  • bin / magento设置:升级
  • bin / magento缓存:刷新

0

我认为先禁用模块是明智的

php bin / magento模块:禁用模块

因为这会检查依赖项...


0

从magento 2卸载扩展程序:

  1. 在CLI中转到您的magento项目目录,并通过运行命令检查模块状态 php bin/magento module:status

  2. 如果启用,则通过运行命令将其禁用 php bin/magento module:disable <extension name>

  3. 转到数据库并搜索“ setup_module”表,然后搜索您的扩展名并将其删除

  4. 从应用程序/代码文件夹中删除您的扩展名文件夹

  5. 运行setup:upgrade命令。

  6. 您已成功卸载了该扩展程序。


0

这是逐步指南,可手动卸载MAGENTO 2的任何第三方模块。

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

自定义Magento2模块

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.

有关卸载第3方/ composer已安装扩展的更多信息

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


如果您想保留同一供应商提供的不同模块怎么办?您的SQL查询将破坏这些。
多米尼克·希根

刚刚编辑了我的答案。
Arshad Syed

0

Magento 2:如何卸载模块

1.如果您手动安装它:

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.如果您是通过作曲家安装的:

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

希望有人得到帮助


1
在安装composer.json的那天之后,我刚刚创建了不使用composer.json文件的模块,是否可以使用composer卸载模块?我的模块=> github.com/ZusZus/simple-module/tree/master/app/code/Gta/Mymod @matinict
zus

@zus为避免冲突,首先您需要从应用程序/代码中删除代码,是的,我认为您可以通过composer进行安装/卸载((您的模块链接可能不适用于composer的安装,您需要添加您的repo packagist.org))
matinict

-7
  1. 打开 setup/src/Magento/Setup/Console/Command/ModuleUninstallCommand.php

并更换

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;
}

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. 打开 setup/src/Magento/Setup/Model/ModuleUninstaller.php

并更换

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);
}

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. 说“ lyaska masyaska”

注意,不建议在生产服务器上使用该解决方案

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.