Search by

adachsoft / code-operations-mql5

Arkadiusz Adach

MQL5 code validation and MetaEditor runtime discovery for the AdachSoft Code Operations API.

Package info

gitlab.com/a.adach/code-operations-mql5

Issues

pkg:composer/adachsoft/code-operations-mql5

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-12-02 00:19 UTC

This package is auto-updated.

Last update: 2026-12-01 23:20:12 UTC


README

adachsoft/code-operations-mql5 implements the shared adachsoft/code-operations-contracts API for MQL5 projects. It validates MQL5 syntax with MetaEditor and exposes the configured MetaEditor installations as runtimes.

Installation

Install the library with Composer:

composer require adachsoft/code-operations-mql5

Requirements

  • PHP 8.3 or newer.
  • MetaTrader 5 with MetaEditor installed on Windows.
  • For WSL, PHP runs on Linux and the configured MetaEditor executable path ends in .exe.
  • In WSL, project, temporary log, and optional include paths must be accessible below /mnt/<drive>.

In WSL mode, the adapter maps /mnt/d/path/to/file.mq5 to D:\path\to\file.mq5 for MetaEditor. MetaEditor logs are read as UTF-16LE and parsed for compiler diagnostics. The process exit code is not used to determine validation success because MetaEditor may return an unreliable value.

Usage

<?php

declare(strict_types=1);

use AdachSoft\CodeOperationsContracts\ExecutionContextDto;
use AdachSoft\CodeOperationsMql5\MetaEditorInstallationDto;
use AdachSoft\CodeOperationsMql5\Mql5CodeOperations;
use AdachSoft\CodeOperationsMql5\Mql5RuntimeResolver;
use AdachSoft\CommandExecutorLib\SimpleCommandRunner;

$operations = new Mql5CodeOperations(
    new Mql5RuntimeResolver([
        new MetaEditorInstallationDto(
            version: '5',
            binaryPath: '/mnt/c/Program Files/OANDA TMS MT5 Terminal/MetaEditor64.exe',
            includePath: '/mnt/c/Users/username/AppData/Roaming/MetaQuotes/Terminal/terminal-id',
        ),
    ]),
    new SimpleCommandRunner(),
);

$context = new ExecutionContextDto(
    projectPath: '/mnt/d/projects/my-mql5-project',
    runtime: null,
    timeoutSeconds: 60,
);

$result = $operations->validate($context);

When ExecutionContextDto::$paths is empty, validation selects all .mq5 files recursively, excluding .git, vendor, and node_modules. When paths are supplied, the adapter validates the selected relative .mq5 and .mqh files. A configured include directory is passed to MetaEditor with /inc.

Limitations

  • Only the validate operation is supported. MetaEditor is invoked in syntax-check mode (/s), so no .ex5 file is generated.
  • test() and run() throw the contract's UnsupportedOperationException.
  • Projects must contain an .mq5 or .mqh file to be supported.

Integration tests

The mql5 integration group uses the real MetaEditor when METAEDITOR_PATH is set. CODE_OPERATIONS_TMP must name an existing directory under /mnt/<drive>; temporary MQL5 projects are created there. Without METAEDITOR_PATH, the integration tests are skipped. The default vendor/bin/phpunit run includes this group.

To run the integration group explicitly in WSL:

METAEDITOR_PATH='/mnt/c/Program Files/OANDA TMS MT5 Terminal/MetaEditor64.exe' \
CODE_OPERATIONS_TMP='/mnt/d/tmp/code-operations' \
vendor/bin/phpunit --group mql5