5 minutes to read

Using composer for plugin installation in Shopware

Using composer for plugin installation in Shopware

Did you ever wonder what composer is and why it is so en vogue to use it if you are a developer? Composer is a so-called dependency manager for PHP projects. When "composing" the PHP project of your choosing, it will check which server environment the application requires and will install exactly the correct library version you will need on your server. Additionally, composer runs on the command line and thus perfectly fits for automation processes of your deployment. There is no need anymore to manually download the zip file from our website, unpack it and upload it via FTP on your server. However, these zip files are just artifacts made with composer ;) If you already know how to install Shopware with composer, you might want to skip the next paragraph.

Installing Shopware itself with composer

As a prerequisite, you have already installed PHP in a supported version according to our documentation plus, the necessary extensions like php-mysql, php-xml, php-curl etc. Of course, you would need composer as well. Best, go for this tutorial: https://getcomposer.org/download/

As Shopware is a Symfony application, we use template skeletons to let Shopware itself run. There are two different templates available: Development which is used mostly if you want to take part in Shopware development and production which perfectly fits if you want to run your own customer project. You most likely want to go for the production template in this case, download it:

git clone https://github.com/shopware/production shopware

This was quickly done, wasn't it? Now change into the new folder with cd shopware and use the following command:

composer install

Composer will now collect all needed libraries and other components according to your system. In case a PHP extension was not installed properly or is missing, it will let you know.

In the next step, we need to set up the environment. This will be done with the builtin Shopware console:

bin/console system:setup

Finally, run

bin/console assets:install

to install the browser installer. As an alternative, you can also run bin/console system:install --create-database --basic-setup to skip the browser installer and add your database connection etc. already here, in the terminal.

There are manyfold options and variants to customize your project already at this early stage. Please see the README.md file of this repository for more information: https://github.com/shopware/production

Installing plugins in Shopware with composer

Of course, you want to customize your fresh Shopware installation. Besides theme changes, there is a possibility to add or overwrite existing functionality via plugins. There are many plugins already available "in the wild" under an open source license which are easy to install via composer as most of them use packagist as a distribution channel.

All you have to do is run the following command from the DocRoot (where composer.json file resides):

composer require vendor/plugin_name

Afterward, you can easily activate this plugin via the console and start working with it:

bin/console plugin:refresh
​
bin/console plugin:install –-activate plugin_name

However, please read the installation instructions of every single plugin you want to use carefully on their README pages.

Installing licensed plugins in Shopware with composer

But also, other plugins that you bought from the Shopware store, can be installed via composer. Basically, you need just an authentication token for your own Shopware installation. Intrigued to know how it works? Christian explains the necessary steps in this video:

There is another sort of extensions which are available for functional enhancements: the so-called Apps. In difference to plugins, Apps make only use of the Shopware RESTful API. Unfortunately, Apps cannot be installed via composer.

Did you know? The possibility to install plugins via composer was first evolved by the Friends of Shopware project and has been taken over into the core later.

Do you like this blog post or have any questions? Don't hesitate to reach out on our Stackoverflow channel.

Newsletter

Never miss out - get all the latest news sent straight to your inbox.

To the newsletter manager