How to install shopware plugin with composer

How to Install Shopware 6 Plugin from Store via Composer

Installing plugins with the composer is very handy when you deploy your Shopware 6 using a CD pipeline. The sources of the purchased plugins don't need to be pushed to your project code repository anymore. Thus the codebase becomes cleaner.

Prerequisites

  • Create a Shopware account if you don't have one yet.
  • Register your Shopware online store.
  • At the Shopware Store purchase the plugin you would like to install and associate this plugin with your Shopware online store.

First Time Project Composer Configuring

The first step is to install composer-installer-extender composer plugin.
It will enable a non-standard (from the composer perspective) installation directory for our plugins, which is custom/plugins. Because, by default, the composer installs everything in vendor/ directory.

composer require oomphinc/composer-installers-extender:~2.0

Next, declare the custom plugins directory in the composer.json:

composer config --json extra.installer-types '["shopware-platform-plugin"]' \ 
&& composer config --json extra.installer-paths '{"custom/plugins/{$name}": ["type:shopware-platform-plugin"]}' 

Add the Shopware package repository to your composer.json by running:

composer config repositories.shopware '{"type": "composer", "url": "https://packages.shopware.com/"}'

Authentication

Log in to your Shopware account. Select the shop in the Merchant area and scroll down to the plugin list. Select any of them and click "Install via composer". In the popup window, generate a new token if you don't have one yet. Copy and execute the command for setting up the authentication token:

composer config bearer.packages.shopware.com "abcdefABCDJDCCXXDLJJFghijklm,noppsdkd/.kkd=="

The token should be saved in auth.json. It should look like this example below:

{
    "bearer": {
        "packages.shopware.com": "abcdefABCDJDCCXXDLJJFghijklm,noppsdkd/.kkd=="
    }
}

Installing Shopware Plugin

Find the package you would like to install and run:

composer require store.shopware.com/plugin-packagename

Once it completes, run:

./bin/console plugin:refresh

Your freshly installed plugin should be visible in the list. Finally, execute the plugin install and activate commands to get the plugin active.

./bin/console plugin:install --activate pluginname

That's it, happy installing!

FacebookTwitterPinterest