Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer.json is replaced when installing magento 2 #1351

Closed
jamescowie opened this issue Jun 8, 2015 · 6 comments
Closed

Composer.json is replaced when installing magento 2 #1351

jamescowie opened this issue Jun 8, 2015 · 6 comments
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@jamescowie
Copy link

When using composer to install magento 2 from this repository: https://github.com/magento/magento2-community-edition E.g. composer create project magento/magento2-community-edition then there is no way to add dependencies to the project to start with using composer require or require-dev as the composer.json file is replaced with that from the main magento 2 repository.

This makes it hard for automated build tools to create the initial project containing Behat and PHPSpec for example. One solution would be to merge the 2 composer.json files into a single file and place in the first repository.

@buskamuza
Copy link
Contributor

Hi @jamescowie ,

could you, please, describe your workflow?
Usually, you should use that repository to create a project, so you should have composer.json from that repository + all Magento files. Then you should not update your project from the repository anymore. Instead, if you want to update Magento version, you should change it here - https://github.com/magento/magento2-community-edition/blob/master/composer.json#L11 and run composer update. The composer.json should not change, so you can add any dependencies you want.

If you want to add other dependencies before even installing the project, you can use composer create-project --no-install and run composer install only when all dependencies are added.

@jamescowie
Copy link
Author

Hello,

So the workflow Im using is that I create a composer.json file that contains:

magento/magento2-community-edition,
behat,
phpspec,
phpunit
....

It looks like this repository is only useful as the magento community package is loaded from packages.magento.com and not available via packagist and a default instal.

Is there an alternative workflow that will mean that I can create a composer.json file that is not replaced ?

This is more prominent in our case as we use an automated build tool that "seeds" each project.

@buskamuza
Copy link
Contributor

Hi @jamescowie ,

Let's clarify couple things:

  1. You say you specify magento/magento2-community-edition in your composer.json. magento/magento2-community-edition is not a composer name, you should use either magento/project-community-edition, if you consider Magento as a base for your project, or magento/product-community-edition, if you use Magento as a dependency.
  2. What do you mean under "a composer.json file that is not replaced"? On which step is it replaced in your case: is it a Composer command that does something with composer.json or is it because you use git pull to update the project from https://github.com/magento/magento2-community-edition ?

The workflow I'd imagine is the following:

  1. To create a Magento project you use following commands:
composer create-project --stability=beta --no-install magento/project-community-edition .
composer require --no-update behat
composer require --no-update phpspec
...
composer install

2 . As a result, you'll have a composer.json with dependencies you need and all of them will be installed:

"require": {
        "magento/product-community-edition": "0.74.0-beta12",
       .....
},

3 . When you want to update Magento to the newer version, you can either change above version in composer.json manually or use composer require command:

composer require magento/product-community-edition:0.74.0-beta13

4 . As a result, your composer.json will remain unchanged (except your intentional changes of the version) and new versions of all Magento packages will be loaded.

@jamescowie
Copy link
Author

Hello,

Thanks for clearing that up. The confusion for me came as I found 3 different repositories that could be used:

magento/magento2
magento/magento2-community-edition
magento/product-community-edition

However you are correct the workflow should be that when a new Magento project needs to be created a person will run:

composer create-project --stability=beta --no-install magento/project-community-edition ProjectName

Then by either editing the composer.json file or running composer require etc new dependencies to the project can be added, At any point composer install can be ran here.

I tested this by modifying composer.json to revert to the previous version of the beta and behat still remained as well as re upgrading to the latest version. Only issues I found was that I define bin-dir to be /bin and during downgrade / upgrade the bin dir was removed. I have a feeling this is either a configuration option we can add to composer.json so there is a new node:

"bin": ["bin/magento"]

Or it may be an issue that needs to be looked at more within the composer realm.

My only other point around this is that we and many people use version control so when we create the project we will add all the project files excluding the vendor directory and others. For Magento 2 this add's all /lib and /app/code/Magento so when we do run composer update the files that are modified also require committing back to the repository. What I prefer and is the approach taken by others is that "framework" code is loaded via the vendor directory.. However there is another issue #1206 that if completed would lead the way to move more Magento owned code into vendor.

@buskamuza
Copy link
Contributor

@jamescowie , good point about bin. It should be enough to update bin/magento and bin/.htaccess instead of whole bin directory. I created an internal ticket to fix it - MAGETWO-38518

@sshrewz sshrewz added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 14, 2015
@piotrekkaminski
Copy link
Contributor

This issue should be already fixed. Please reopen if persists.

magento-team pushed a commit that referenced this issue Jul 20, 2017
magento-engcom-team pushed a commit that referenced this issue Feb 6, 2018


 - Merge Pull Request magento-engcom/magento2ce#1351 from magento-engcom-team/magento2:batch-29-forwardport-2.3-develop
 - Merged commits:
   1. 70dd5a3
   2. 54bc3a1
   3. 3debd3f
   4. 72c4965
   5. e60ecdf
   6. 8703b3d
   7. bd88ed8
   8. 1c70b18
   9. 5fd7481
   10. 7c61506
   11. 2653b8a
   12. 917a03f
   13. eca73d0
   14. 26f3109
   15. c223484
   16. 3b90ad7
   17. ad317c2
   18. 53e721c
   19. 6114120
   20. 63b4839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

5 participants