When writing an extension, would it make sense to add magento/project-community-edition to the require-dev section of composer.json?

The idea behind that is that it would only require a composer install to spin up a complete Magento installation for development or CI.

To set up the database, I would add a post-install script with bin/magento setup:install.

To use the testing tools, you'd need to copy the autoload-dev and require-dev sections from magento/project-community-edition because those are only used from the root, not from requirements.

One disadvantage that I see is that you'd have to change the required version to test on more than two different versions (two because you can specify a range and install once with --prefer-lowest), but that's relatively easy to work around.

Anything else that I need to consider?

4 Answers 4


The answer depends on what your CI needs are.

For unit tests I am currently looking into the approach to only include in the require section the actual Magento modules I have as direct dependency (that I get nearly all modules this way anyway is for Magento to sort out):

"require": {
  "magento/module-backend": "~100.0.2",
  "magento/module-sales": "~100.0.2"

This works well for one of my extensions see Travis here but is running into an interesting issue on another extension where Magento should autogenerate an interface for a mock - details here.

If you are looking beyond unit tests I think it makes sense to have a pre-built Magento environment in which you install the extension into rather than running an install script for Magento environment on every build.


Looks reasonable. 2 points to keep in mind:

  1. Installation via composer takes quite some time
  2. When you have a bunch of modules, it’s quite uncomfortable to support/handle installation procedure inside CI with scripts that are unique for each module. When you need to alter something here, you'd have to change all extensions you have.

One of the ways to avoid it, could be keeping everything related to the build on CI in a separate repository and include it in modules as subrepositories.

Posted on behalf of Peter Samoilov from aheadWorks since he's not on StackExchange. :)


It makes sense to include only the Magento modules that your module requires:

  • It's clear for everyone installing it what it depends on, the whole community edition is too broad.
  • You probably want to mainly unit test it (and some integration tests), so it doesn't need a functioning webshop.
  • The functional tests can be created in your main webshop repository, as there it makes more sense to use a frontend and also depend on the whole framework as interconnected things.

Basically your module itself does not depend on the whole community edition, it only depends on a part of it so that's what to specify. This way you can still test it, but also keep clear what the dependencies are.


also not sure about this. My first approach will be to install magento2 from a docker image to run all tests.

This will give you a running test env in a pretty short time, but you have to create a more build specific configuration than installing everything via composer i think.

Your Answer

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

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