Hi there,

 I was recently given advice that Drupal core and it’s modules are best updated using Composer. I am not a Developer by nature and therefore am looking for some guidance as to how on earth this is achieved. If there are links people know of that could be helpful to this topic (using user-friendly terminology if this exists) it would be very much appreciated :)

thanks all

Comments

hiramanpatil’s picture

mmjvb’s picture

... were given bad advice.

First step would be to verify whether the composer solution would be a fit for your circumstances. Verify with your provider whether and if so, how to use composer. It is very common not to be able to use composer on shared servers. Not saying it is impossible, just saying it is not in your service.

Second step would be to start your project with composer. Advice against introducing composer to an existing site. Not saying it is impossible, just saying it isn't that easy. Looks like Drupal console can produce a json from existing site. Also there are several distributions showing how to start with composer.

Third step would be to be conservative with updating. Although it is good practice to keep current, that doesn't mean you should update everything to the latest. Suggest to avoid .0 releases and test your updates. That means update as little as possible and verify important functionality to still work as expected.

You asked for links but I haven't found any, hence I wrote my opinion above.

Red2015’s picture

Thanks for the help here, much appreciated. It is for an existing site, on shared servers, so not off to a favourable start.

The reason for asking was an attempt to update the site manually failed, I tried updating core on its own, then extension by extension, but I was either met by an error message or the white screen of doom. Fortunately I had done it locally so no harm done, but haven’t tried to update since. I posted a question at the time on the forums, apparently the update had failed because the php needed some sort of structure for updating core/its extensions safely, and composer helped with this. I had no further information on how to go about using it.

Is there another way to update core and extensions safely that I maybe am unaware of? Or is Composer the only way to update sites safely?

Thanks again for the help.

mmjvb’s picture

to update. The manual way is normally the solution to running into problems the other way. Problems with the manual way need to be investigated and resolved. Normally that means you did something wrong, backtrack and don't make the same mistake again.

It is common to upgrade a copy of the site and replace live site when upgraded successfully. That procedure is depending on your circumstances. 

bburch’s picture

I updated from 8.8.2 to 8.8.3. Here’s a couple things I had to work through.

ISSUE #1: CORRECT PACKAGE NAME?

There are multiple Composer.json files, but you need to edit the file in the directory above your site’s root directory.

You’ll know you have it when the file begins with some introductory information:

{

    "name": "drupal/recommended-project",

    "description": "Project template for Drupal 8 projects with a relocated document root",

    "type": "project",

    "license": "GPL-2.0-or-later",

    "homepage": "https://www.drupal.org/project/drupal",

    "support": {

        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",

        "chat": "https://www.drupal.org/node/314178"

    },

In that file, the installed distro is “recommended-project" (listed at the top of the file).  

BUT “core-recommended” will be the update that Composer pulls from packagist.org, the PHP package repository:

 https://packagist.org/packages/drupal/core-recommended

You can see this listed in the “require” section of the file:

"require": {

        "composer/installers": "^1.2",

        "drupal/core-composer-scaffold": "^8.8",

        "drupal/core-project-message": "^8.8",

        "drupal/core-recommended": "8.8.*"   

ISSUE #2: EDIT COMPOSER VERSION CONTROL

Composer uses “^8.8” for major versions, but “8.8.*” will also update minor versions.

https://en.wikipedia.org/wiki/Composer_(software)

cf. “Versions” section with table covering commands

I wanted to upgrade from 8.8.2 to 8.8.3, so I had to change the file’s version control to do that minor  update.

In the original file, all the code in the “require” section used "^8.8", e.g.:

           

        "drupal/core-recommended": "^8.8",

In the corrected code, I changed that to:

        "drupal/core-recommended": "8.8.*"

--------------

With “composer.json” file edited, you’re ready to update with the correct package name:

“composer update drupal/core-recommended –with-dependencies”