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": ">=8.0",
        "ext-curl": "*",
        "ext-openssl": "*",
        "symfony/dotenv": "^5.1"
    },
    "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 >=8.0 is 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>\\": ""
  }
},