Composer.json for an OXID eShop Module

OXID eShop modules with metadata version greater 2.0 are installed via Composer by using the OXID eShop Composer Plugin.

In order to install a module correctly, this plugin requires four fields to be described in module composer.json file:

PayPal module example:

{
    "name": "oxid-esales/paypal-module",
    "description": "This is the PayPal module for the OXID eShop.",
    "type": "oxideshop-module",
    "keywords": ["oxid", "modules", "eShop"],
    "homepage": "https://www.oxid-esales.com/en/home.html",
    "license": [
        "GPL-3.0-only",
        "proprietary"
    ],
    "require": {
        "php": ">=5.6",
        "lib-curl": ">=7.26.0",
        "lib-openssl": ">=1.0.1",
        "ext-curl": "*",
        "ext-openssl": "*"
    },
    "autoload": {
        "psr-4": {
            "OxidEsales\\PayPalModule\\": ""
        }
    }
}

name

This is the name the OXID eShop module will be publicly known and installable. E.g. in our example you could type

composer require oxid-esales/paypal-module

type

Module must have oxideshop-module value defined as a type. This defines how the repository should be treated by the installer.

require

Here you must define all dependencies your module has. You must define:

  • a minimum PHP version. In the example PHP >=5.6 is required

  • the required system libraries and their versions, if applicable. In the example lib-curl >=7.26.0 and lib-openssl >=1.0.1 are required

  • the required PHP extension and their versions, if applicable. In the example the PHP extensions curl and openssl must be activated

  • the required composer components, if applicable. In the example the are no requirements defined

Autoload

Composer autoloader is used to load classes. In order to load module classes the module needs to register it’s namespace to the root module path:

"autoload": {
  "psr-4": {
    "<vendor>\\<module-name>\\": ""
  }
},