Installing Bootstrap theme using Composer I am new to using Composer.

How can I install a theme, say https://www.drupal.org/project/bootstrap using composer

I've tried:

composer require drupal/bootstrap


But didn't work.

I also tried:

composer require twbs/bootstrap


Installation was completed successfully but I couldn't see the theme appearing at Drupal admin page.

What is the standard way to extract the name of the theme or module to be used with composer require?
That is because every Drupal package is at drupal/ - twbs is not in the Drupal packagist. You have to add that to composer to get that to work as Clive said.

It is not in the composer.json file out of the box.

You need to add that, and then do:

composer remove twbs/bootstrap because this is NOT a Drupal ready theme.

After adding the repository to composer.json, then you can do:

composer require drupal/bootstrap

Also, not every module or theme has a composer.json file yet. Bootstrap for Drupal does, and thats where you can determine what the package name is if you are unsure.

http://cgit.drupalcode.org/bootstrap/tree/composer.json

I believe modules/themes have to provide this file in order to work with composer (including the repository addition in Clives answer).

Here is one of my projects composer.json, for example. Note the addition of the repositories and Drupal packages URL.

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0+",
    "require": {
        "composer/installers": "^1.0.21",
        "wikimedia/composer-merge-plugin": "~1.3",
        "drupal/search_api_solr": "1.0.0-beta1",
        "drupal/search_api": "^1.0@beta"
    },
    "replace": {
        "drupal/core": "~8.2"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "repositories": {
        "drupal": {
            "type": "composer",
            "url":  "https://packages.drupal.org/8"
        }
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php."
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": false,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "modules/contrib/{$name}": ["type:drupal-module"],
            "themes/contrib/{$name}": ["type:drupal-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup"
    }
}


The lack of the packages repository in composer.json is a small, easily missed and often overlooked thing. Hopefully it will be added in a future release.