1

I'm installing Magento 2.2 via command line using

php bin/magento setup:install --backend-frontname="my-admin-value" --db-host=my.db.host --db-name=dbname --db-user=dbuser --db-password=dbpass --base-url="http://example.com" --language=en_US --timezone="Europe/Bucharest" --currency="EUR" --use-secure=1 --base-url-secure="https://example.com/" --admin-user=adminUser --admin-password=AdminPass --admin-email="[email protected]" --admin-firstname=John --admin-lastname=Doe --use-rewrites=1

And it works fine, but now I want to install it and skip the at least 2 core modules because I don't need them. Let's say they are Magento_Bundle and Magento_BundleImportExport.
(Ignore the fact that there might be dependent module on these. I don't care for now. Let's say I can disable the modules when installing via UI wizard).
How can I do that? Is it even possible? Is there a parameter I need to pass to the command?
I've tried running the command with -h but nothing comes up related to modules.

1
  • I am always installing Magento 2 via meta package via composer, and those packages/modules are in the composer.json so it does not seem to me that you can prevent them from installing. Nov 7, 2017 at 19:09

3 Answers 3

1

Check the output of bin/magento help setup:install. There are arguments for modules to enable or disable during installation:

--enable-modules[=ENABLE-MODULES]     List of comma-separated module names. That must be included during installation. Available magic param "all".
--disable-modules[=DISABLE-MODULES]   List of comma-separated module names. That must be avoided during installation. Available magic param "all".
1
  • 1
    ah. this was added for 2.3. I asked the question for 2.2. But I'll take it. Time to upgrade anyway. Thanks
    – Marius
    Jun 18, 2020 at 6:17
2

Since all the modules are separate composer packages, I think you can disable them in composer.json. What I will describe is not a good solution, and it is kind of a hack.

First of all, I have installed Magento 2 with the following command,

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2.2

Secondly, I have removed modules you mentioned from vendor directory via the following command.

rm -Rf vendor/magento/module-bundle*

Then, I have added the following part into composer.json right after the require field.

"replace": {
    "magento/module-bundle": "100.2.0",
    "magento/module-bundle-import-export": "100.2.0"
},

So, this will say composer that those packages are already provided by your application. As a result, composer will not bother to install them again, since it is trusting what you say (We lied :().

After that you can run composer install or composer update again, and you won't see these packages in your vendor directory.

The final version of my composer.json file

{
    "name": "magento/project-community-edition",
    "description": "eCommerce Platform for Growth (Community Edition)",
    "type": "project",
    "version": "2.2.0",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "require": {
        "magento/product-community-edition": "2.2.0",
        "composer/composer": "@alpha"
    },
    "replace": {
        "magento/module-bundle": "100.2.0",
        "magento/module-bundle-import-export": "100.2.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~6.2.0",
        "squizlabs/php_codesniffer": "3.0.1",
        "phpmd/phpmd": "@stable",
        "pdepend/pdepend": "2.5.0",
        "friendsofphp/php-cs-fixer": "~2.1.1",
        "lusitanian/oauth": "~0.8.10",
        "sebastian/phpcpd": "2.0.4"
    },
    "autoload": {
        "psr-4": {
            "Magento\\Framework\\": "lib/internal/Magento/Framework/",
            "Magento\\Setup\\": "setup/src/Magento/Setup/",
            "Magento\\": "app/code/Magento/"
        },
        "psr-0": {
            "": [
                "app/code/"
            ]
        },
        "files": [
            "app/etc/NonComposerComponentRegistration.php"
        ],
        "exclude-from-classmap": [
            "**/dev/**",
            "**/update/**",
            "**/Test/**"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
            "Magento\\Tools\\": "dev/tools/Magento/Tools/",
            "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
            "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
            "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
        }
    },
    "minimum-stability": "stable",
    "repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        }
    ],
    "extra": {
        "magento-force": "override"
    }
}

EDIT 1: Actually, this method is used in the official Magento repository. But they are providing those modules in the app/code directory. The only difference that you won't :).

2
  • This seems to work. But It skips the dependencies check. For example I was able to install magento without the bundle module but the msrp module depende on it. I don't know how this will impact me in the future. I'm kind of scared to take this approach on long term. Anyway, I will investigate further and come back with results.
    – Marius
    Nov 8, 2017 at 8:07
  • 1
    Ok. I got some results fast. I cannot run setup:di:compile. I get an error Invalid Factory for nonexistent class Magento\Bundle\Api\Data\OptionInterface. this is a result of the skipped dependency check. So it works in theory, but it's a risky way to do it. If you don't know what you are disabling you can easily get into trouble.
    – Marius
    Nov 8, 2017 at 8:13
1

Magento CLI comes with the module:status command which lists the statuses of existing modules. If you run it before installation you'll see that all the modules are enabled. Now, run module:disable passig the list of modules to disable. Run setup:install command after that.

1
  • This kind of works. The draw back is that I have to add the app/etc/config.xml upfront with all the modules and disable them one by one. The good part is that when disabling the module there is a check for dependencies and I know if I can disable it or not.
    – Marius
    Nov 8, 2017 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.