I have my own module installed via composer and I can uninstall it with

php bin/magento module:uninstall XXX_XXX

But when I reinstall the module the configuration (values in system.xml) is still the same as it was setup while it was installed before. Do I have to remove the configurations manually? How?

EDIT: My current Uninstall class:


namespace XXXX\XXXXX\Setup;

use Magento\Framework\Setup\UninstallInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\Setup\ModuleContextInterface;

    class Uninstall implements UninstallInterface
        public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context) {

            $connection = $setup->getConnection();


1 Answer 1


The uninstall-command actually only removes anything when you invoke it with --remove-data and your module has an Uninstall class that implements Magento\Framework\Setup\UninstallInterface. I believe if you want to remove configuration values, you can also do this here.

The official documentation is a place to start: http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli-uninstall-mods.html


As far as I can see, the Uninstall class does not have access to the configuration by default, so you should define an own constructor to fix this. Code is shortened and untested:


class Uninstall implements UninstallInterface
     * @var \Magento\Framework\App\Config\ConfigResource\ConfigInterface
    protected $resourceConfig;

    public function __construct(  
        \Magento\Framework\App\Config\ConfigResource\ConfigInterface $resourceConfig
    ) {
        $this->resourceConfig = $resourceConfig;


Then, in your uninstall()-function, use that interface's deleteConfig() method to delete your configuration:

  • I have an Uninstall Class in my module and the commands in there are getting called when uninstalling. But I am not doing anything manually with the configuration in there. Does that mean I have to remove the normal configuration data by hand in the Uninstall file? How do I do that?
    – alobeejay
    Jun 26, 2017 at 12:08
  • Can you post your code? Jun 26, 2017 at 14:06
  • I don't have any code that deletes the configuration. That is what I need.
    – alobeejay
    Jun 27, 2017 at 10:46
  • Can you please share your uninstall class? Jun 27, 2017 at 10:47
  • Sure. I edited my post above.
    – alobeejay
    Jun 27, 2017 at 10:52

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.