Drupal 9 Composer

  1. Drupal 9 Composer Free
  2. Update Drupal 9 With Composer
  3. Drupal 8 Composer

According to the official Drupal documentation, to create a new site using composer you should use a composer template project called drupal/recommended-project. This has a default composer.json file setup with some values that will help you get up and running swiftly with a new Drupal project. It's a good initiative to get you up and running with a standard Drupal site pretty quickly. Using Composer is far and away the easiest method to install Drush. The best way to use Drush 9 is to include it in your project. First install Composer if you don't have it already. Follow the latest instructions from the official source, getcomposer.org and then return here. Now that you have Composer, you can include drush in your project. Trying to upgrade a D8.8.6 site to D9 - karins-MBP:d9civicrm.local sysadmin$ composer require drupal/core-recommended:[email protected] drupal/core-composer-scaffold:[email protected] -update-with-dependencies -no-update./composer.json has been updated karins-MBP:d9civicrm.local sysadmin$ composer update.



Besides all standard system requirements like PHP (>=7.3), a web server like Apache or Ngnix, and a database (e.g., MySQL), you need to have composer installed on your local machine. If you haven't, take a look at the installation instructions on the official site.

Download Drupal 9 via composer

Since Drupal 8.8.0, there is an official composer template to download the Drupal core and all its dependencies. So, it's not recommended to use the inofficial composer drupal-project anymore. There are a few differences between them both, but in the end, it's just about the (not) installed vendor packages. Open your terminal and let composer do the work.

This composer command will download the core and all dependencies into YOUR_DIR. It'll also configure some stuff you'll need in your composer.json.

Use Drush to install Drupal

Now that is everything in place you have to install Drupal. One way is the install script, which will start if you visit your site URL like myproject.local. I prefer to use Drush – the Drupal shell. The new recommended-projectdoesn't include drush by default, so we have to require it.


We will use the standard installation profile, feel free to choose whatever fits your needs. You also need to have your database and related credentials ready.

Adjust (development) settings

I assume we're setting up Drupal for local development stuff here, but of course, you can adjust these settings for production or staging environments.

First, we make the sites/default directory writeable and create a new subfolder sites/default/settings. After that, we copy the settings.php generated while the installation process to this new folder and call it settings.shared.php. Why? Because we want to split our settings into two separate files so that we can easily change environment settings. Another way of doing this would be to use an .env file. Feel free to choose any method.

Next, we're going to replace all content within the standard settings.php and include our newly generated settings.shared.php.


Update drupal 9 with composer

In our shared settings file, add the settings for trusted_host_patterns (for security reasons).


Next, we need to include the local settings file, which we will create after that.

Now, move your local database settings array from/web/sites/default/settings/settings.shared.php to our new/web/sites/default/settings/settings.local.php.


For local development, you need to include your development.services.yml file,turn off render and page caching, enable verbose error logging, and disable JavaScriptand CSS preprocessing. To do so, add these lines below your database array.

Now we need to disable the Twig caching via the included /web/sites/default/development.services.yml.Your file should look like this:

It's time to clear the Drupal cache to be sure our new settings will be applied!

Install drupal using composer

Drupal 9 Composer Free

Now your Drupal 9 installation should be ready, and all settings should be suitableto start local development. But caution! You need to do two more things to secureyour installation!

Update Drupal 9 With Composer

First, give your files directory and your settings.php the right permissions:

Drupal 8 Composer

And as always, never commit a settings file to your git repository! So add our newlocal settings file to the .gitignore in the root directory.