28 votes
Accepted

How can I force Composer to install a dev branch over a stable release?

While it will install the latest dev release of the Drupal module/theme to simply do the following: composer require drupal/bootstrap:3.x-dev I would argue a best practice when installing a dev ...
  • 2,871
26 votes
Accepted

Composer keeps overwriting .htaccess (and other files) every time I do anything

That's Drupal's Composer Scaffold. Listed as "drupal/core-composer-scaffold": "^8.8.0" or a different version in your project's composer.json file. To prevent certain scaffold files from being ...
  • 17k
25 votes

"Uncaught ReflectionException: Class DOMDocument does not exist" error

DOMDocument is included in the extension php-xml. To install it on ubuntu, run: sudo apt-get install php-xml
23 votes
Accepted

composer require fails because it can't delete default.services.yml

Make your "local" machine work as intended, and maintain the security of your live site. Since you want to use composer require command only on non-production environments, the following ...
  • 610
22 votes
Accepted

Is Drush abandoned?

You have installed the development master branch of Drush. To continue using commands such as drush dl, drush pm-update and so on, you should install the 8.x branch of Drush. However, your basic ...
17 votes
Accepted

Require v8 only contrib module with v9 patch

Drupal 10 As reported by @rocketeerbkw, the official lenient endpoint in packagist currently doesn't support Drupal 10. https://github.com/mglaman/composer-drupal-lenient does. Instructions for use ...
  • 4,053
16 votes
Accepted

How to add JavaScript or CSS library to Composer project?

The library can be installed into a custom path by utilizing extra : installer-paths to for e.g.: web/sites/libraries/{$name} Additional to that, we define the required package repository with the ...
  • 301
16 votes

How can I force Composer to install a dev branch over a stable release?

You can keep the original prefer-stable settings. The @dev in 8.3.*@dev is the stability flag for the given package. The easiest way to force a dev-version of a package is to use a different version ...
  • 656
16 votes
Accepted

Installation error with Composer

Please make sure your webserver (nginx/apache) is using the same PHP version as your cli one. For example, you may encounter this issue if your cli PHP version is PHP 7.1 and your webserver is using ...
  • 628
15 votes

How do I uninstall Drush?

You can use composer global remove drush/drush to uninstall a global Drush. Or use composer remove drush/drush to uninstall a project-local Drush.
15 votes
Accepted

Composer updates .htaccess file when updating

"extra": { "drupal-scaffold": { "source": "http://cgit.drupalcode.org/drupal/plain/{path}?h={version}", "excludes": [ ".htaccess", "robots.txt" ] } } Put this above code in ...
15 votes

How can I install a beta version of a module?

This installs the latest beta-12 for me: composer require drupal/webform:5.0.*@dev You need to do a bit of translation from the Drupal version number. From Using Composer to manage Drupal site ...
  • 165k
14 votes

Drush CC all returning "No Drupal site found, only 'drush' cache was cleared"

There are a few things you can do to help debug your drush. Here is what you can try: Debug output Use drush cc all -vvv This will provide you with some valuable information in terms of what Drush ...
14 votes
Accepted

Error when attempting to create sync directory

Nothing wrong with that. It is recommend to have the config folder outside of the public web folder; Drupal just doesn't have that. To keep the installation simple for non-experienced users, it puts ...
  • 82.2k
14 votes

composer require fails because it can't delete default.services.yml

This command will fix it temporarily: chmod u+w web/sites/default But Drupal will harden permission again soon. To turn it off add this to settings.php: $settings['skip_permissions_hardening'] = TRUE;...
  • 441
14 votes
Accepted

Trouble after updating to 2.0

In order to resolve the composer/installers ^1.7 issue you can require composer/installers ^1.9. More details can be found from Drupal's Preparing your site for Composer 2. composer require "...
13 votes
Accepted

How to install multiple modules with composer at once?

You can write the names of multiple packages separated by spaces. For example: composer require drupal/adminimal_theme:^1.5 drupal/adminimal_admin_toolbar:^1.9
  • 2,884
12 votes
Accepted

Updating Drush with Composer

If you want to update your global installations of any package under composer, you can just do this: composer global update You don't need to navigate to .composer/vendor/drush/drush However: There ...
  • 2,505
12 votes

How do I apply a patch with Composer workflow?

First, run composer require cweagans/composer-patches Now you have a package installed that enables you to patch core, libraries or modules. Second, add a patch to a folder named 'patches' in the ...
12 votes
Accepted

`composer require` fails because "Source directory docroot/core has uncommitted changes"

Explanation: The problem is that cweagans/composer-patches is applying patches to Drupal Core after cloning it, leading Composer to believe you've modified the affected files and therefore to prompt ...
12 votes
Accepted

Command to install Drupal 9 with Composer

create-project can take a version number, and recommended-project has some tags in for 9.x, so for example: composer create-project drupal/recommended-project mynewproject "9.0-beta1" Or if you just ...
  • 165k
12 votes
Accepted

drupal/core vs. drupal/core-recommended

It's "core-recommended" as in "recommended to avoid having dependency-related trouble with core." Drupal core (and some of the contributed modules, but not all) has a variety of ...
11 votes
Accepted

What is the correct core update workflow?

I presume that you are using drupal-composer/drupal-project as the basis for your project. If not, take a look at that project, and compare it with yours. Also, you said that you want to use ...
11 votes
Accepted

How to download a module hosted on GitHub via composer.json?

You need Composer Installers for that: { "name": "my-project", "type": "project", "repositories": [ { "type": "composer", "url": "https://packages.drupal....
  • 165k
11 votes
Accepted

How to install with composer external library that drupal module depends on

You should be able to include this package via composer by adding some repository info. Add a package definition to your repositories section in your composer.json. The resulting repositories section ...
  • 7,472
10 votes

How do I update core with Composer?

To update Drupal using Composer, you just need to move the "drupal/core": "~8.1" line from the replace section to the require section. At the end the content of the composer.json file is like the ...
  • 95.7k
10 votes

How do I apply a patch with Composer workflow?

The issue is that composer is applying patches using git apply which is not working for packages that are not installed from source. Therefore the solution is to install the packages from source. ...
10 votes

composer update drupal/drupal does not work : Nothing to install or update

Finally, i could update with these modifications. Step 1, optional in case your composer.jsoncontains this. If it is ok, apply step 2 add "require": { --- "drupal/core": "~8.5" ...
10 votes

Drush on production server without Composer

If you don't want composer in production on your server, you can run the composer commands locally to install Drush, then make sure to push the vendordirectory to the server. Make sure to also commit ...
  • 16.4k
10 votes
Accepted

Is it possible to make a patch that modifies a module's composer.json?

This issue is actually addressed in the composer-patches documentation: Because patching occurs after Composer calculates dependencies and installs packages, changes to an underlying dependency's ...
  • 26.6k

Only top scored, non community-wiki answers of a minimum length are eligible