0

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="me@example.com" --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.

  • 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. – Bunyamin Inan Nov 7 '17 at 19:09
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.

  • 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 '17 at 7:54
1

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 :).

  • This seems to work. But I 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 '17 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 '17 at 8:13

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.