layout | group | subgroup | title | menu_title | menu_node | menu_order | version | github_link | redirect_from | ||
---|---|---|---|---|---|---|---|---|---|---|---|
default |
install_cli |
05_Command-line installation |
Uninstall modules |
Uninstall modules |
8 |
2.0 |
install-gde/install/cli/install-cli-uninstall-mods.md |
|
You should uninstall a module only if you're certain you won't use it. Instead of uninstalling a module, you can disable it as discussed in Enable or disable modules.
This command checks only dependencies declared in composer.json
. If you uninstall a module that is not defined in composer.json
, this command uninstalls the module without checking for dependencies. This command does not, however, remove the module's code from the Magento file system. You must use file system tools to remove the module's code (for example, rm -rf <path to module>
.
As an alternative, you can disable non-Composer modules.
magento module:uninstall [--backup-code] [--backup-media] [--backup-db] [-r|--remove-data] [-c|--clear-static-content] \
{ModuleName} ... {ModuleName}
where {ModuleName}
specifies the module name in <VendorName>_<ModuleName>
format. For example, the Magento Customer module name is Magento_Customer
. To get a list of module names, enter magento module:status
The module uninstall command performs the following tasks:
-
Verifies that the specified modules exist in the code base and are packages installed by Composer.
This command works only with modules defined as Composer packages.
-
Checks for dependencies with other modules; if there are any, the command terminates..
To work around this, you can either uninstall all modules at the same time or you can uninstall the depending modules first.
-
Requests confirmation to proceed.
-
Puts the store in maintenance mode.
-
Processes the following command options.
Option Meaning Backup file name and location --backup-code
Backs up the Magento file system (excluding
var
andpub/static
directories).var/backups/<timestamp>_filesystem.tgz
--backup-media
Backs up the
pub/media
directory.var/backups/<timestamp>_filesystem_media.tgz
--backup-db
Backs up the Magento 2 database.
var/backups/<timestamp>_db.gz
-
If
--remove-data
is specified, removes the database schema and data defined in the module'sUninstall
classes.For each specified module to uninstall, invokes the
uninstall
method in itsUninstall
class. This class must inherit from Magento\Framework\Setup\UninstallInterface. -
Removes the specified modules from the
setup_module
database table. -
Removes the specified modules from the module list in the deployment configuration.
-
Removes code from the codebase using
composer remove
.Uninstalling a module always runs
composer remove
. The--remove-data
option removes database data and schema defined by the module'sUninstall
class. -
Cleans the cache.
-
Updates generated classes.
-
If
--clear-static-content
is specified, cleans generated static view files. -
Takes the store out of maintenance mode.
For example, if you attempt to uninstall a module that another module depends on, the following message displays:
magento module:uninstall Magento_SampleMinimal
Cannot uninstall module 'Magento_SampleMinimal' because the following module(s) depend on it:
Magento_SampleModifyContent
One alternative is to uninstall both modules after backing up the Magento module file system, pub/media
files, and database tables but not removing the module's database schema or data:
magento module:uninstall Magento_SampleMinimal Magento_SampleModifyContent --backup-code --backup-media --backup-db
Messages similar to the following display:
You are about to remove code and/or database tables. Are you sure?[y/N]y
Enabling maintenance mode
Code backup is starting...
Code backup filename: 1435261098_filesystem_code.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Code backup path: /var/www/html/magento2/var/backups/1435261098_filesystem_code.tgz
[SUCCESS]: Code backup completed successfully.
Media backup is starting...
Media backup filename: 1435261098_filesystem_media.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Media backup path: /var/www/html/magento2/var/backups/1435261098_filesystem_media.tgz
[SUCCESS]: Media backup completed successfully.
DB backup is starting...
DB backup filename: 1435261098_db.gz (The archive can be uncompressed with 7-Zip on Windows systems)
DB backup path: /var/www/html/magento2/var/backups/1435261098_db.gz
[SUCCESS]: DB backup completed successfully.
You are about to remove a module(s) that might have database data. Remove the database data manually after uninstalling, if desired.
Removing Magento_SampleMinimal, Magento_SampleModifyContent from module registry in database
Removing Magento_SampleMinimal, Magento_SampleModifyContent from module list in deployment configuration
Removing code from Magento codebase:
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Removing magento/sample-module-modifycontent (1.0.0)
Removing Magento/SampleModifycontent
- Removing magento/sample-module-minimal (1.0.0)
Removing Magento/SampleMinimal
Writing lock file
Generating autoload files
Cache cleared successfully.
Generated classes cleared successfully.
Alert: Generated static view files were not cleared. You can clear them using the --clear-static-content option. Failure to clear static view files might cause display issues in the Admin and storefront.
Disabling maintenance mode
Errors display if you attempt to uninstall a module with a dependency on another module. In that case, you cannot uninstall one module; you must uninstall both.
magento setup:rollback [-c|--code-file="<filename>"] [-m|--media-file="<filename>"] [-d|--db-file="<filename>"]
where <filename>
is the name of the backup file located in <your Magento install dir>/var/backups
. To display a list of backup files, enter magento info:backups:list
This command deletes the specified files or the database before restoring them. (For example, the --media-file
option deletes media assets under pub/media
before restoring from the specified rollback file.) Make sure you have made no changes to the file system or database that you want to keep before using this command.
To display a list of available backup files, enter magento info:backups:list
This command performs the following tasks:
-
Puts the store in maintenance mode.
-
Verifies the backup file name.
-
If you specify a code rollback file:
a. Verifies the rollback destination locations are writable (note that the
pub/static
andvar
folders are ignored).b. Deletes all files and directories under your Magento 2 installation directory.
c. Extracts the archive file to the destination locations.
-
If you specify a database rollback file:
a. Drops the entire Magento database.
b. Restores the database using the database backup.
-
If you specify a media rollback file:
a. Verifies the rollback destination locations are writable.
b. Deletes all files and directories under
pub/media
c. Extracts the archive file to the destination locations.
-
Takes the store out of maintenance mode.
For example, to restore a code (that is, file system) backup, enter the following commands in the order shown:
-
Display a list of backups:
magento info:backups:list
-
Restore a file backup named
1433876616_filesystem.tgz
:magento setup:rollback --code-file="1433876616_filesystem.tgz"
Messages similar to the following display:
Enabling maintenance mode Code rollback is starting ... Code rollback filename: 1433876616_filesystem.tgz Code rollback file path: /var/www/html/magento2/var/backups/1433876616_filesystem.tgz [SUCCESS]: Code rollback has completed successfully. Disabling maintenance mode
To run the magento
command again without changing directories, you might need to enter cd `pwd`
- Installing the Magento software using the command line
- [Remove sample data modules or update sample data]({{ page.baseurl }}install-gde/install/cli/install-cli-sample-data-other.html)
- [Enable or disable modules]({{ page.baseurl }}install-gde/install/cli/install-cli-subcommands-enable.html)
- [Display or change the Admin URI]({{ page.baseurl }}install-gde/install/cli/install-cli-adminurl.html)
- Create or update the deployment configuration
- Enable or disable maintenance mode
- Create the Magento database schema
- [Update the Magento database schema and data]({{ page.baseurl }}install-gde/install/cli/install-cli-subcommands-db-upgr.html)
- Configure the store
- Create or unlock a Magento administrator
- [Back up and roll back the file system, media, and database]({{ page.baseurl }}install-gde/install/cli/install-cli-backup.html)
- [Uninstall themes]({{ page.baseurl }}install-gde/install/cli/install-cli-theme-uninstall.html)
- [Uninstall language packages]({{ page.baseurl }}install-gde/install/cli/install-cli-uninstall-langpk.html)
- Uninstall the Magento software
- Update the Magento software
- Reinstall the Magento software