UPCOMING: Magento 2 Bootcamp of four days in The Netherlands (April 29th - May 2nd)

February 16, 2017

Using composer with commercial Yireo extensions

Yireo Blog Post

With Magento 2, composer is supported out of the box. Free extensions can easily be downloaded via public repositories like GitHub. However, for commercial extensions we have decided to setup our own private repository that can be accessed through a subscription URL. This guide explains how to install commercial Magento 2 extensions created by Yireo.

Quick start

As example, we will assume an extension Yireo_FooBar with 1234 as software key.

Next, open up a command prompt (SSH or local terminal) and navigate to your Magento shop. Run the following commands:

composer config repositories.yireo-foobar composer https://api.yireo.com/composer.php/key,1234/
composer require yireo/magento2-foobar

For instance, for DeleteAnyOrder 2, you could use the package yireo/magento2-deleteanyorder2 and for EmailTester 2, you could use the package yireo/magento2-emailtester2.

And to finalize:

./bin/magento module:enable Yireo_FooBar
./bin/magento cache:flush
./bin/magento setup:upgrade

Your subscription key

When you have purchased a commercial Magento 2 extension from us, you will get access to various resources on our site, all available under your Yireo Account. The Downloads link brings you to downloadable packages of your extension. However, with Magento 2 we recommend you to use composer instead.

{highlight}All you need is your subscription key{/highlight}

Under the Subscriptions link you will find your subscriptions, both active and expired. For each subscription, there is an automatically generated Software Key that gives you access to our composer repository.

The link to our composer repository is active for as long as the subscription is active. Once the subscription expires, the composer link is also no longer valid. It will then return an empty response.

Our api.yireo.com server

Our subscription server is accessible through the address api.yireo.com and specific composer calls go to https://api.yireo.com/composer.php/. This is not a webservice, but a simple PHP script that interprets the given URL arguments and then responds with the appropriate JSON data.

To construct your subscription URL, you will need the Software Key of your subscription. For obtaining the Software Key, see the procedure above. In this example we will use Yireo_FooBar as extension and 1234 as key. The actual subscription URL will look like this:

https://api.yireo.com/composer.php/key,1234/

You should replace 1234 with your own subscription key. As you can see, this subscription URL does not specify the extension itself. The extension is found by our server automatically, because each subscription is linked to a specific extension.

The URL can be copied and pasted in your browser to confirm that it is working. If it is not working, the output will look like this (with a HTTP Status 40X):

{"packages":[]}

When working correctly, the output will be something like this:

{"packages":{"yireo\/Yireo_FooBar":{"0.0.1":{"name":"yireo\/magento2-foobar","version":"0.0.1","dist":{"url":"https:\/\/api.yireo.com\/composer.php\/key,1234\/resource,download\/request,Yireo_FooBar_composer_0.0.1.zip","type":"zip"}}}}}

To install the actual Magento 2 extension using composer, see the rest of this guide.

Configuring your URL in composer

This procedure requires you to have Magento 2 already installed through composer, and you to know basic composer procedures.

To add your subscription URL to your composer configuration, you can use the following command:

composer config repositories.yireo-foobar composer https://api.yireo.com/composer.php/key,1234/

To break this down: The command configures (config) a specific element in the composer.json file, namely repositories. To this array of repositories, a specific new repository is added. It is named magento2-foobar but this in fact could be any name. Next, the repository is of type composer (just like Satis and Packagist). The final argument is your subscription URL itself.

Running composer

Once our subscription URL is added to your composer.json file, you can use regular composer commands to access downloads:

composer require yireo/magento2-foobar

This should download and install the composer package. Once down, you can verify whether the extension files are present under vendor/yireo/magento2-foobar. Once the files are there, you can install the extension in Magento 2:

./bin/magento module:enable Yireo_FooBar
./bin/magento cache:flush
./bin/magento setup:upgrade
Posted on February 16, 2017

About the author

Author Jisse Reitsma

Jisse Reitsma is the founder of Yireo, extension developer, developer trainer and 3x Magento Master. His passion is for technology and open source. And he loves talking as well.

Sponsor Yireo

Looking for a training in-house?

Let's get to it!

We don't write too commercial stuff, we focus on the technology (which we love) and we regularly come up with innovative solutions. Via our newsletter, you can keep yourself up to date on all of this coolness. Subscribing only takes seconds.

Do not miss out on what we say

This will be the most interesting spam you have ever read

We don't write too commercial stuff, we focus on the technology (which we love) and we regularly come up with innovative solutions. Via our newsletter, you can keep yourself up to date on all of this coolness. Subscribing only takes seconds.