6 Easy Steps To Install Drupal With Composer

6 Easy Steps To Install Drupal With Composer

steps to install drupal with composer

Composer is now the method of choice for installing Drupal, as it is the preferred method. Both the installation of Drupal’s core as well as contributed modules and themes can make use of this resource. Check out our concise yet in-depth step-by-step guide to installing Drupal Composer.

Drupal Installation Requirements

If you have settled on Drupal as the platform upon which to construct your website, you will need to ensure that the prerequisites for CMS installation are met. A web server and a database server are required for the procedure as they are the two fundamental components. The fundamental stack of the most widely used operating systems makes calls to AMP, which is an acronym for the following:

  • Web pages are served using Apache (or another web server, such as Nginx),
  • MySQL (or another server for a database, such as MariaDB),
  • (PHP) (in a version that is supported by a certain release of Drupal).

In order to ensure a successful installation of its core, you will need to ensure that you satisfy the requirements of the specific Drupal version you are using.

Why Should You Make Use of Composer When Installing Drupal 8 or 9?

Composer is a piece of software that assists in the management of PHP dependencies. Why is this method of installing Drupal 8 or 9 more convenient than others? In the first place, it makes the maintenance of Drupal and its dependencies, such as modules, libraries, themes, and so on, simple and visible. In addition to this, it verifies that the most recent version of each module and theme has been installed on your website. In addition to this, there is an official project that simplifies the installation of Drupal with Composer. It is complete with all of the necessary information that is required for this procedure. Composer is highly recommended for the installation of Drupal, and the aforementioned reasons are just a few of the many reasons why. We could write down other reasons, but that is not the goal of this text.

Drupal Installation with Composer – Step-by-Step

Before Composer became popular, the most frequent method for installing Drupal was done so through the use of Drush or the Drupal Console. At this time, Composer takes care of the download procedure on its own. You will find the necessary instructions for installing Drupal with Composer further down in this article.

1. Install Composer

The installation of Composer on your local system is the first and most significant item that has to be done. On that page, you may look for step-by-step instructions that explain how to carry out the aforementioned steps using a variety of operating systems, such as Windows, macOS, or Linux.

2. Download Drupal Core Using Composer

Composer template drupal/recommended-project is what you need to use in order to successfully download Drupal 8 or 9 core. As a result, you will have the peace of mind of knowing that the fundamental dependencies are compatible with the official release. Since Drupal 8.8.0, the default template has shifted from drupal-composer/drupal-project to the actual drupal/recommended-project directory. This is an important change that should be noted.

In order to successfully install Drupal 8 or 9, you should use the following command:

composer create-project drupal/recommended-project my_site_name_dir

The drupal/recommended-project package will be downloaded directly to the my_site_name_dir directory when you use this command. It will automatically activate the composer install command, which will download the most recent stable versions of Drupal core as well as any dependencies Drupal may have.

In my_site_name_dir you can find all files unavailable for the web server and those which should be placed out of the webroot.

3. Download a Specific Drupal Core Version via Composer

The command that was just described will download the most recent version of Drupal, such as 9.2.0. You will need to use a separate command in order to download a different version, such as Drupal 8.9.1, for example.

composer create-project drupal/recommended-project:8.9.1 my_site_name_dir

4. Download Contributed Modules and Themes Using Composer

You have already completed the installation of the core of Drupal. It is time to start expanding its capabilities by adding modules and themes at this point. You can accomplish all you need to do with Composer. You will need to execute the following command at the root of your Drupal site in order to download the donated module or theme along with all of its external dependencies:

composer require drupal/<modulename>

Let’s take it for granted that it will be a Pathauto module. The command will then look like this after that:

composer require drupal/pathauto

Pathauto will be added to the requirements in the updated composer.json that will be generated by Composer.

Pathauto will be added to the requirements in the updated composer.json that will be generated by Composer.

5. Download a Specific Version of Contributed Modules or Themes

In a manner analogous to that which was described for Drupal’s core, you can specify the version of a module or theme you want to install. In order to make this, use the following command:

composer require ‘drupal/<modulename>:<version>’

For example:

composer require ‘drupal/pathauto:^1.8’

6. Changing Locations of Packages

You have the ability to specify where the downloaded packages should be installed after they have been extracted. In order to make this work, you will need to edit the “installer-paths” section of the composer.json file. Utilize the following configuration:

“extra”: {

“installer-paths”: {

“core”: [“type:drupal-core”],

“libraries/{$name}”: [“type:drupal-library”],

“modules/contrib/{$name}”: [“type:drupal-module”],

“profiles/contrib/{$name}”: [“type:drupal-profile”],

“themes/contrib/{$name}”: [“type:drupal-theme”],

“drush/{$name}”: [“type:drupal-drush”],

“modules/custom/{$name}”: [“type:drupal-custom-module”],

“themes/custom/{$name}”: [“type:drupal-custom-theme”]

 } 

}

Without using Composer, how would one go about installing Drupal 8 or 9?

Composer was described before as a method that is suggested to use while installing Drupal. There are, however, other options available to you in the event that you do not wish to or are unable to make use of Composer. Installing Drupal via the command line using Drush is just one example of the many options available.

In a nutshell, you need to incorporate the following command into your project:

composer require drush/drush

and then use drush site:install.

Managing Drupal Site with Composer

Composer isn’t just for installing Drupal 8 or 9, though it can do that too. You’ll have no trouble using it to manage updates to Drupal’s core, as well as upgrades to additional modules, themes, and libraries. Check out the following links if you are looking for a reputable source of information on this topic.

Conclusion

Composer significantly accelerates and simplifies the processes involved in installing Drupal 8 or 9. You will no longer be required to manually download the CMS core, and in addition to this, you will be able to utilize the tool in the future to manage your site along with its dependencies. 

Moreover, if you are looking for a Drupal development company that can help you with all your Drupal-related solutions then you should check out Appic Softwares. We have an experienced team of Drupal developers that will assist you.

You can even hire dedicated Drupal developers from us and let them manage your project. So, what are you waiting for?

Contact us now!

Get Free Consultation Now!


    Contact Us

    Consult us today to develop your application.

      Get in touch with us


      Skype Whatsapp Gmail Phone