Articles in this section

Upgrading from Composer 1 to 2 in PHP applications on Upsun

Goal

With the release of Composer 2, you might want to use it in your PHP application.

Assumptions

You already have a Upsun  project set up and a .upsun.app.yaml that is configured accordingly for PHP.

Problems

Upsun PHP images ship with Composer 1.

Steps

Since you can declare additional dependencies via your .upsun.app.yaml, Composer 2 can be required like this:

dependencies:
    php:
        composer/composer: '^2'

Conclusion

After you commit and push your changes, with the next build and redeploy, the application container will get Composer 2 (both during build and runtime):

web@app.0:~$ composer --version
Composer 2.0.2 2020-10-25 23:03:59

Subsequent installs in the hooks should use composer 2.

 

Additional Notes

Currently all Upsun images should be using composer 2, if  you encounter errors such as: - 
You are using an outdated version of Composer warning.

It may mean the plugin you are install is incompatible with composer 2 and will fallback to composer 1

To verify if it’s indeed a specific plugin that does cause that message to be displayed, run grep '"composer/composer":' composer.lock :
If the output doesn’t include composer ^2.0.0, as in the 3rd line of the following output, then the linked plugin probably needs an update.

  "composer/composer": "~1.0 || ~2.0",
               "composer/composer": "^1.0 || ^2.0",
               "composer/composer": ">=1.2.0 <1.7.0 || ^1.7.1",
               "composer/composer": ">=1.5.6 <1.7.0 || ^1.7.1 || ^2.0.0",

More information regarding the “caret version range operator” can be found in composer’s documentation below:

https://getcomposer.org/doc/articles/versions.md#caret-version-range- 

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.