For Drupal 9, We should use "drupal/recommended-project" composer template. This will ensure that Drupal core dependencies are same as the official Drupal release.
Composer command is as below to create Drupal 9 project
composer create-project drupal/recommended-project first_drupal9_site
This command will create a project in "first_drupal9_site" and automatically will execute composer install to download latest stable version of Drupal and all its dependencies.
Now first_drupal9_site directory will have files as below.
1. composer.json (file)
2. composer.lock (file)
3. vendor (Directory)
4. web (Directory)
The web root will be "web" directory. Except "web" directory, all other files "composer.json, composer.lock, vendor" will not accessible to the web server.
To install Drupal 9 site, now access your localhost and access web directory. Follow the steps as per installation asks. Once these steps will finish, your first Drupal 9 site will ready.
To install specific version, run below composer command.
composer create-project drupal/recommended-project:9.4.8 first_drupal9_site
To do modified installation
Before composer install execution, if I need to modify some of the properties of the downloaded composer.json then we have to use --no-install flag while running composer create-project.
Example, if I want to rename the subdirectory "web" to something else. Follow below steps
- Run command composer create-project --no-install drupal/recommended-project first_drupal_site
- Change directories to first_drupal_site and edit the composer.json file to suit your needs.
For example, to change the sub-directory from 'web' to something else, the keys to modify are the 'extra' sub-keys 'web-root' (under 'drupal-scaffold') and 'installer-paths'.
- Run composer install to download Drupal and all its dependencies.
- Run composer require drupal/module_name. eg. composer require drupal/token
- This needs to be executed at the root of your Drupal install but not at the same level as the core directory.
No comments:
Post a Comment