{"id":57311,"date":"2023-07-30T18:11:14","date_gmt":"2023-07-30T12:41:14","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=57311"},"modified":"2023-08-28T18:25:46","modified_gmt":"2023-08-28T12:55:46","slug":"how-to-update-drupal-core-with-composer","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-update-drupal-core-with-composer\/","title":{"rendered":"How to update Drupal core with composer"},"content":{"rendered":"<p>It&#8217;s good practice to update the Drupal core and contribute modules to the latest released version. Let&#8217;s dive into how to update the Drupal core. There are multiple ways to update the core, but here we are discussing with the composer only. Composer is also the recommended way to manage the dependency of Drupal.<\/p>\n<p>First, try it on the dev\/local environment. Don&#8217;t try to update directly on the production. Take a backup of the code, database, and files.<\/p>\n<p>also put the site in maintenance mode &amp; rebuild the cache.<\/p>\n<pre class=\" language-php\"><code class=\"bash language-php\">drush state<span class=\"token punctuation\">:<\/span>set system<span class=\"token punctuation\">.<\/span>maintenance_mode <span class=\"token number\">1<\/span>\r\ndrush cache<span class=\"token punctuation\">:<\/span>rebuild<\/code><\/pre>\n<h2>\u00a0Choose the target Drupal version.<\/h2>\n<p>Before starting the update, we need to know the current version of our Drupal core and the newly released version of Drupal. It could be either a minor or major update. To know the updated version, we can run the below command.<\/p>\n<pre class=\" language-php\"><em><strong>composer outdated \"drupal\/*\"<\/strong><\/em>\r\nit will list all the available updates we can check drupal\/core in the list as shown in the screen below. \r\n<img decoding=\"async\" loading=\"lazy\" class=\"alignleft wp-image-57308\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-300x35.png\" alt=\"know the latest version\" width=\"480\" height=\"56\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-300x35.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-1024x118.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-768x89.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-624x72.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update.png 1402w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/pre>\n<p>&nbsp;<\/p>\n<p>We can also check the Drupal release page; it shows all released based on the Drupal major version. We can check the performance and highlights of the update.<\/p>\n<p>In my case, my project is based on Drupal 9.5.5, while the latest released version is Drupal 9.5.8. So, we are planning to update from 9.5.5 to 9.5.8 minorly.<\/p>\n<p>https:\/\/www.drupal.org\/project\/drupal\/releases\/9.5.8<\/p>\n<h4>Verify whether the project uses Drupal\/core-recommended or Drupal\/core<\/h4>\n<p>run <em><strong>composer show drupal\/core-recommended<\/strong><\/em> in the terminal<\/p>\n<p><strong>(a)<\/strong> If the above command returns &#8220;Package drupal\/core-recommended not found&#8221;, it means drupal\/core-recommended is not installed using the Drupal\/core only, in that case, we can run the below command to update the core.<\/p>\n<pre class=\" language-php\"><code class=\" language-php\">composer update drupal<span class=\"token operator\">\/<\/span>core <span class=\"token operator\">--<\/span>with<span class=\"token operator\">-<\/span>dependencies\r\n<\/code><\/pre>\n<p><strong>(b)<\/strong>\u00a0 If the above command (<em><strong>composer show drupal\/core-recommended<\/strong><\/em>) shows some info about core recommend:<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-57309\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended-300x95.png\" alt=\"core-recommended\" width=\"300\" height=\"95\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended-300x95.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended-1024x324.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended-768x243.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended-624x198.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-recommended.png 1487w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/>As you can see on the screen, it&#8217;s showing the info about the core-recommended, then we can run the below command to update the Drupal core.<code class=\" language-php\"><\/code><\/p>\n<p><code class=\" language-php\">composer update <span class=\"token string\">\"drupal\/core-*\"<\/span> <span class=\"token operator\">--<\/span>with<span class=\"token operator\">-<\/span>all<span class=\"token operator\">-<\/span>dependencies<\/code><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-57310\" src=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-dr-300x128.png\" alt=\"core update drupal\" width=\"300\" height=\"128\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-dr-300x128.png 300w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-dr-768x329.png 768w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-dr-624x267.png 624w, \/blog\/wp-ttn-blog\/uploads\/2023\/05\/core-update-dr.png 981w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Run database update<\/h2>\n<pre class=\" language-php\"><code class=\" language-php\">drush updatedb\r\ndrush cache<span class=\"token punctuation\">:<\/span>rebuild\r\nand disable the m\r\n\r\n# Disable site maintenance mode\r\n<\/code><\/pre>\n<pre class=\" language-php\"><code class=\"bash language-php\">drush state<span class=\"token punctuation\">:<\/span>set system<span class=\"token punctuation\">.<\/span>maintenance_mode <span class=\"token number\">0<\/span>\r\ndrush cr<\/code><\/pre>\n<p>#verify the update<\/p>\n<p>On the\u00a0<strong>reports-&gt;available<\/strong>\u00a0updates page, you can verify if the Drupal website is updated or not.<\/p>\n<h4 class=\" language-php\"><code class=\"bash language-php\"><\/code><\/h4>\n<pre class=\" language-php\"><code class=\"bash language-php\"><\/code><\/pre>\n<pre class=\" language-php\"><code class=\" language-php\"><\/code><\/pre>\n<div class=\"ap-custom-wrapper\"><\/div><!--ap-custom-wrapper-->","protected":false},"excerpt":{"rendered":"<p>It&#8217;s good practice to update the Drupal core and contribute modules to the latest released version. Let&#8217;s dive into how to update the Drupal core. There are multiple ways to update the core, but here we are discussing with the composer only. Composer is also the recommended way to manage the dependency of Drupal. First, [&hellip;]<\/p>\n","protected":false},"author":1509,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":32},"categories":[3602],"tags":[5214,4862],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57311"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1509"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=57311"}],"version-history":[{"count":3,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57311\/revisions"}],"predecessor-version":[{"id":58185,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/57311\/revisions\/58185"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=57311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=57311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=57311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}