Install Drupal using composer I'am trying to install Drupal 7 using composer. Before that I tried to install drupal 8 using composer and it works perfectly.

Now when I try to install D7 using same method it is still installing D8 instead of D7. I set up package repository as mentioned here but still installing D8 only. I tried $ composer clearcache also but no difference. Please help.
Checking https://packagist.org/packages/drupal/drupal for the versions available there is NO 7.x version. Drupal 7 has no composer.json for this to command to work.

You can use one of the other 2 methods mentioned on https://www.drupal.org/docs/develop/using-composer/using-composer-to-manage-drupal-site-dependencies

Using https://github.com/drupal-composer/drupal-project you need to tell the version

composer create-project drupal-composer/drupal-project:7.x-dev \
  test-3 --stability dev --no-interaction


Using https://github.com/hussainweb/drupal-composer-init you can do

composer drupal-init --drupal-7


Please note:


applying core patches seems tricky or even not working. The core tree (whole web root) is deleted then reapplied. But then ie sites/all/modules gets emptied. See


https://github.com/cweagans/composer-patches/issues/42
https://github.com/drupal-composer/preserve-paths/issues/10
In https://github.com/cweagans/composer-patches/issues/42#issuecomment-288365507 a patch is available but that seems NOT to work 100%