# Composer Setup

## Open source packages 
All open source packages - including the main core module `LokiCheckout_Core` - are maintained via GitHub ([LokiCheckout](https://github.com/LokiCheckout) and [LokiExtensions](https://github.com/LokiExtensions)) and distributed via Packagist ([loki-extensions](https://packagist.org/users/loki-extensions/packages/)).

You don't need a license key or any further composer setup for the open source packages. For example, to get started:

```bash
composer require loki-checkout/magento2-core
bin/magento module:enable `bin/magento module:status | grep -E 'Yireo|Loki'`
```

## Your license key
To access packages under a paid plan, you will need use your license key in composer.

Login to your account at the [Loki Shop](https://shop.loki-extensions.com/). Navigate to **My Account** and then **My Software**. In the overview of software subscriptions, pick the one of your choice and click **Details**. On the detail page, you can find details of your software subscription, including the license key. Copy the license key. Below, it is referenced as `YOURLICENSE`.

## Register the license key in composer
Run the following commands in your Magento project. Replace `YOURDOMAIN` with the domain name of your Magento instance (for instance, `example.com`) and `YOURLICENSE` with the actual license key.

```bash
composer config --auth http-basic.composer.loki-extensions.com YOURDOMAIN YOURLICENSE
```

After this, you should have a `auth.json` file with the following details. Note that this file could be located in the root of your Magento directory, in the home of composer (identified with the shell variable `$COMPOSER_HOME`) or theoretically elsewhere. You probably know best:

```json
{
    "http-basic": {
        "composer.loki-extensions.com": {
            "username": "YOURDOMAIN",
            "password": "YOURLICENSE"
        }
    }
}
```

## Configure the `composer.loki-extensions.com` repository
Now, configure the `composer.loki-extensions.com` repository in your main `composer.json` by running the following command:

```bash
composer config repositories.loki-extensions composer https://composer.loki-extensions.com/
```

After this, your `composer.json` should be including a repository like the following (and note that the rest of your `composer.json` file is not taken into account here):

```json
{
    "repositories": {
        "loki-extensions": {
            "type": "composer",
            "url": "https://composer.loki-extensions.com/"
        }
    }
}
```
