cancel
Showing results for 
Search instead for 
Did you mean: 

Questions about Composer

Questions about Composer

I'm finally getting around to planning my migration away from 1.9x. The first thing that really stands out so far is the use of composer which is even seemingly required to install magento itself, but also packages.

 

In M1 I always just installed things manually but uploading to ftp or unzipping in root. Although, I knew of modman, I never used it because it seemed a bit complicated for me at the time. And I didn't find it very difficult manually installing anyway.

 

But with composer being able to install/uninstall by using composer require/remove seems really handy. Are those the only 2 commands or is there more to know?

 

Am I incorrect in comparing this to modman?

 

It seems to me that composer can install from cloud (such as repo.magento.com) or possibly some local path on disk. Is that true or did I misunderstand or read that incorrectly somewhere (I forget the source).

 

If so how do you configure where they are locally, and is the procedure for installing different than from cloud? Or is that basically like the old fashion way of uploading by sftp or unzipping in root and then using composer require to "initialize"?

 

Lastly, how does this work with source control such as git? Normally I will deploy new things to development branch/dev server and then after sufficient testing, pull on production.

 

If a package is installed on development branch and then I pull the code to production. Naturally here, the only thing I'm getting is code and no database changes. So will I still need to use composer to "initialize" the extension even on production?

 

Thanks

1 REPLY 1

Re: Questions about Composer

Hi @ZenMasta,

 

I'll try to help with some of your questions:

 

"But with composer being able to install/uninstall by using composer require/remove seems really handy. Are those the only 2 commands or is there more to know?"

 

Well, composer install could be usefull when you need to install upgrades of the code.

 

"Am I incorrect in comparing this to modman?"

 

Is incorrect because Composer is not a Package manager. Is a dependency manager. And Modman, if I recall correctly, doesn't manage the dependencies. https://github.com/colinmollenhour/modman/wiki/Tutorial

 

"It seems to me that composer can install from cloud (such as repo.magento.com) or possibly some local path on disk. Is that true or did I misunderstand or read that incorrectly somewhere (I forget the source)."

 

You're right. You can use also several packages repositories (for example Packagist or your custom Satis server).

For example, your composer.json should contain something like:

 

"repositories": [
        {
            "type": "composer",
            "url": "https://repo.magento.com/"
        },
        {
            "type": "composer",
            "url": "https://packages.example.com/"
        }
    ]

"If so how do you configure where they are locally, and is the procedure for installing different than from cloud? Or is that basically like the old fashion way of uploading by sftp or unzipping in root and then using composer require to "initialize"?"

 

Maybe you could check here: https://getcomposer.org/doc/05-repositories.md

 

"Lastly, how does this work with source control such as git? Normally I will deploy new things to development branch/dev server and then after sufficient testing, pull on production."

 

You should keep only the composer.json and composer.lock file on your repository. Then the files will be installed and/or updated using composer commands.

 

"If a package is installed on development branch and then I pull the code to production. Naturally here, the only thing I'm getting is code and no database changes. So will I still need to use composer to "initialize" the extension even on production?"

 

From now on your deployment process will include the composer commands and probably database upgrades.

If you branch has new packages or versions to install, Composer will handle. Maybe this link can be useful: https://devdocs.magento.com/guides/v2.3/config-guide/deployment/single-machine.html

 

(My 2 cents)