# ocmod.zip: how to package an OpenCart 3.0 and 4.1 module with install.xml and install.json

> Structure of the .ocmod.zip archive for OpenCart 3.0 and 4.1: upload folder, install.xml, install.json, OCMOD files, updates, and common reasons why Installer rejects the archive.

Джерело: https://opencartcode.com/en/wiki/dev-extensions/ocmod-zip
OpenCart: 3.0, 4.1
Оновлено: 2026-11-24

Examples for [OpenCart](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#opencart) 4.1; in 4.0.x, model triggers and event handling differ.

The ocmod.zip archive is uploaded via the [Extensions](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#extensions) → Installer page, but its internal structure differs between versions. In OpenCart 3.0, files go into the `upload/` folder with the same directory structure as the store, and the modification is described in `install.xml`. In OpenCart 4.1, the root of the archive becomes the extension folder `extension/{код}/`, the module description is in `install.json`, and modifications are in the `ocmod/` folder. Below we cover both schemes, the Installer rules, and the pitfalls when updating.

## What should the archive look like for OpenCart 3.0?

Installer 3.0 accepts only a file whose name ends in `.ocmod.zip`, otherwise it shows "Invalid file type". After upload, the archive is extracted to a temporary directory, and two things are processed:

- **the `upload/` folder**: its contents are moved into the store directories, meaning `upload/admin/` goes to admin, `upload/catalog/` to the catalog, `upload/system/` to `system`, and `upload/image/` to `image`;
- **the `install.xml` file** in the archive root: a OCMOD modification is created from it.

Example

```bash
mymodule.ocmod.zip
├── install.xml
└── upload/
    ├── admin/
    │   ├── controller/extension/module/mymodule.php
    │   ├── language/en-gb/extension/module/mymodule.php
    │   ├── model/extension/module/mymodule.php
    │   └── view/template/extension/module/mymodule.twig
    └── catalog/
        ├── controller/extension/module/mymodule.php
        └── view/theme/default/template/extension/module/mymodule.twig
```

You can't write files just anywhere. Installer 3.0 has a whitelist of directories and stops with the error "The directory … is not allowed to be written to" if a file falls outside them. The list includes:

- `admin/controller/extension/`, `admin/model/extension/`, `admin/view/template/extension/`, `admin/language/`, as well as `admin/view/image/`, `admin/view/javascript/`, `admin/view/stylesheet/`;
- `catalog/controller/extension/`, `catalog/model/extension/`, `catalog/language/`, `catalog/view/javascript/`, `catalog/view/theme/`;
- `system/config/`, `system/library/`, `image/catalog/`.

So you cannot ship your own [controller](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#controller) in `catalog/controller/product/` via the archive. If you need to change a core file, do it through a modification in `install.xml` or through an event, not by replacing the file. In 3.0, files are moved with overwriting: if a file with that path already exists, it will be replaced.

## What should the archive look like for OpenCart 4.1?

In 4.1, extensions live separately from the core, and the archive reflects this directly. The file name without `.ocmod.zip` becomes the extension code and folder name: `mymodule.ocmod.zip` will be extracted to `extension/mymodule/`. Routes, namespaces, and permissions depend on this name, so the archive cannot be renamed after release.

Example

```bash
mymodule.ocmod.zip
├── install.json
├── admin/
│   ├── controller/module/mymodule.php
│   ├── language/en-gb/module/mymodule.php
│   ├── model/module/mymodule.php
│   └── view/template/module/mymodule.twig
├── catalog/
│   ├── controller/module/mymodule.php
│   └── view/template/module/mymodule.twig
├── system/
│   └── library/mymodule/client.php
└── ocmod/
    └── mymodule.ocmod.xml
```

When extracting, Installer 4.1 follows these rules:

- everything from the archive root goes to `extension/{код}/`;
- paths starting with `image/` are copied to the store's shared `image/` directory;
- paths starting with `system/storage/` are copied to the storage directory, for example for [Composer](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#composer) libraries;
- the `ocmod/` folder is not copied: a separate step reads the `*.ocmod.xml` files from it and writes them to the database as modifications;
- items with `..` in the path are skipped.

Installer records every file and directory it creates in the database. So uninstalling in Installer removes exactly what was installed from the archive, nothing extra. Files are extracted in batches of 200, so large archives install too, just over several requests.

Extensions → Installer: uploaded archive and install button · OpenCart 4.1.0.4

> The most common mistake in 4.1: an extra folder at the root of the archive. If you packed the `mymodule/` directory as a whole, the files end up in `extension/mymodule/mymodule/admin/...`, and the core won't find them. Pack the contents of the folder, not the folder itself.

## What should go into install.json and install.xml?

These files describe the extension for the administrator and for the database. Their fields only partly match.

| Field | install.xml (3.0) | install.json (4.1) |
| --- | --- | --- |
| Name | `<name>` | `name` |
| Code | `<code>`, required and unique among modifications | taken from the archive name; the field in JSON does not affect the code |
| Version | `<version>` | `version` |
| Author | `<author>` | `author` |
| Link | `<link>` | `link` |
| Description | none | `description` |

Example

```js
{
  "name": "My Module",
  "version": "1.0.0",
  "author": "Studio Name",
  "link": "https://example.com/mymodule",
  "description": "Блок рекомендацій для сторінки товару"
}
```

**OpenCart 4.1:** without `install.json` in the archive root, Installer rejects the upload with the message "Could not find install.json!". Missing keys are filled with empty strings, so valid JSON with `name` and `version` is the minimum.

**OpenCart 3.0:** `install.xml` is not required, because a module without modifications doesn't need it. If the file is present but there is no `<code>`, installation stops with "Unique code is required for modification XML!", and a code already used by another modification gives "Modification … is already being used!". Build the code from your brand prefix and the module name.

In 4.1 there can be several modifications, one `ocmod/{код}.ocmod.xml` file for each. The modification code is taken from the file name. How to write the OCMOD instructions themselves (`<file>`, `<search>`, `<add>`) is described in detail in the blog article [OCMOD in OpenCart: code changes without modifying system files](https://opencartcode.com/en/blog/ocmod-v-opencart-pravki-kodu-bez-zmini-sistemnix-failiv).

Extensions → Modifications: modification from the archive and the Refresh button · OpenCart 4.1.0.4

After installing an archive with a modification, the administrator must click Refresh (Оновити) on the Extensions → Modifications page (in 3.0 it is Extensions → Modifications, in 4.1 Extensions → Modification; route `marketplace/modification` in both branches), otherwise the changes won't be applied. Mention this in the module's instructions.

## How do you build the archive without surprises?

Build the archive with a script, not manually from a file manager. This way every release has the same structure, and nothing extra gets into it.

Example

```bash
# OpenCart 4.1: пакуємо вміст каталогу, а не сам каталог
cd build/mymodule
zip -r ../../mymodule.ocmod.zip . -x "*.DS_Store" -x "__MACOSX/*" -x ".git/*"

# OpenCart 3.0: у корені архіву лише upload/ і install.xml
cd build/oc3
zip -r ../../mymodule-oc3.ocmod.zip upload install.xml -x "*.DS_Store"
```

Before publishing, check the contents with the `unzip -l mymodule.ocmod.zip` command. The top level must contain `install.json`, `admin/`, `catalog/` in 4.1, or `upload/` and `install.xml` in 3.0.

- **File name.** In 4.1 it becomes the code, so use only lowercase Latin letters, digits, and underscores, with no version in the name. An archive named `mymodule-1.2.ocmod.zip` will create the folder `extension/mymodule-1.2/`, and the next version becomes a separate extension. Moreover, the core builds a PHP namespace from the folder name: it removes underscores but keeps hyphens and dots, and such a namespace becomes invalid.
- **Service files.** `.git`, `node_modules`, tests, SCSS sources: all of this will end up on the client's server. Exclude them via `-x`.
- **Encoding.** Save PHP files as UTF-8 without BOM. A BOM before `<?php` causes "headers already sent" and breaks JSON responses.
- **Two archives for two versions.** The structures are incompatible, so build separate archives for 3.0 and 4.1 and label them in the file name on the marketplace, not inside the extension code.

## How do you release module updates?

Most questions come up with updates, because Installer behaves oppositely in the two versions.

**OpenCart 3.0:** re-uploading the archive overwrites the files, so an update is essentially a new upload. But files you removed from the new version will stay on the server and must be deleted separately. A modification with the same `<code>` is considered taken, so before updating, delete the old modification on the Modifications page.

**OpenCart 4.1:** Installer does not overwrite existing files, and installation stops if the `extension/{код}/` directory already exists. You also can't delete files through Installer while at least one extension from that folder is installed in Extensions → Extensions: Installer will answer that they must be removed first. So the standard admin update path is:

1. In Extensions → Extensions, uninstall each type the module ships. This runs `uninstall()`, and the core deletes the settings from `setting`.
2. In Extensions → Installer, uninstall the installed version. The files, directories, and modifications of this archive are removed according to the recorded list. Then, on the same page, delete the archive itself from the list: otherwise it will remain in `storage/marketplace/`, and uploading a new file with the same name will fail with "already exists".
3. Upload the new archive with the same name, install it, and install the module again in Extensions → Extensions.
4. Click Refresh in Modifications if the module has OCMOD, and save the settings again.

This path loses settings, so account for it when designing the module. Keep data that must survive the update (history, bindings, logs) in your own tables and don't delete them in `uninstall()`. The alternative is updating over the files via SFTP or deployment: settings remain, but Installer won't know about the new files. In both cases, add new columns and events via migrations, as described in the article [install and uninstall of a module](https://opencartcode.com/en/wiki/dev-extensions/install-opencart-module).

## Checklist before publishing the archive

1. The archive is named `{код}.ocmod.zip`; in 4.1 without a version and without hyphens in the code.
2. The top level of the archive matches the version: `upload/` and `install.xml` for 3.0, the extension folder contents and `install.json` for 4.1.
3. In 3.0, all files are in directories from the Installer whitelist.
4. `install.xml` has a unique `<code>`, and `install.json` is valid JSON (check via `php -r 'var_dump(json_decode(file_get_contents("install.json")));'`).
5. The archive is installed on a clean store of the correct version, the module is installed with the Install button, settings are saved, and the [storefront](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#storefront) is checked.
6. The module is uninstalled and installed again: no errors about existing files or modification codes.

The general structure of files that go into the archive is described in the article [anatomy of an extension in 3.0 and 4.1](https://opencartcode.com/en/wiki/dev-extensions/opencart-module-structure). A complete working example is in the material [how to create a module from scratch](https://opencartcode.com/en/wiki/dev-extensions/how-to-create-an-opencart-module).

## Summary

- OpenCart 3.0: files go into `upload/` with a directory whitelist, the modification is in `install.xml` with a required unique `<code>`, and on re-upload files are overwritten.
- OpenCart 4.1: the archive root becomes `extension/{назва архіву}/`, `install.json` is required, modifications are in `ocmod/*.ocmod.xml`, and existing files are not overwritten.
- In 4.1 the archive name is the extension code: stable, in Latin letters, without a version.
- In 4.1, updating means uninstalling in Installer and installing anew, and database changes require migrations.

Other topics about extensions are collected on the page [creating extensions for OpenCart](https://opencartcode.com/en/wiki/dev-extensions).

## FAQ

**Why does Installer say the file already exists when the module has been deleted?**

In 4.1, the uploaded archive stays in storage/marketplace until you remove it from the Installer list. Delete the archive entry, not just the installed extension.

**Can I install a module without Installer, just by copying the files?**

Yes. In 3.0, the files are copied to the same paths as in upload/, and in 4.1 to extension/{код}/. However, OCMOD modifications won't be created automatically, and Installer won't know about these files.

**Can I make one archive for both 3.0 and 4.1?**

No, the archive structures and file paths are incompatible. Make two separate archives with shared business logic in a library.

**What should I do if the hosting limits the upload size?**

Installer depends on upload_max_filesize and post_max_size in PHP. Reduce the archive size by removing service files, or ask your hosting provider to raise the limit.
