Summary: This guide explains how to run legacy Moodle or Totara PHPUnit tooling on PHP 7.4 when the host default PHP version is newer and the standard wrapper keeps resolving nested calls to the wrong binary.

This is the legacy test-tooling case where the project still needs PHP 7.4 but the server default php binary is newer. The awkward part is not only compatibility. It is that some wrapper scripts rebuild PATH in a way that defeats the obvious solution.

Why calling php7.4 directly is not always enough

The SOP notes that Totara’s PHPUnit bootstrap can prepend the directory of PHP_BINARY and then resolve nested php calls against the wrong executable anyway. That is why “just run /usr/bin/php7.4” can still fail.

Use a dedicated PHP 7.4 launcher path

The working pattern is to create a temporary directory with a copied PHP 7.4 binary named simply php:

mkdir -p /tmp/php74bin
cp /usr/bin/php7.4 /tmp/php74bin/php
/tmp/php74bin/php -r 'echo PHP_BINARY, PHP_EOL;'

This gives the wrapper a path it can resolve consistently.

Use a project-local Composer path if needed

If the project’s locked PHPUnit dependencies do not install cleanly under a newer Composer or with newer audit defaults, use a project-local Composer version compatible with the codebase and run it under the same PHP 7.4 launcher.

The important point is to isolate the workaround to the project rather than changing the server’s global tooling casually.

Call the lower-level utility if the wrapper still leaks

If the high-level PHPUnit init wrapper still resolves nested PHP calls incorrectly, bypass it and call the lower-level utility directly:

/tmp/php74bin/php server/admin/tool/phpunit/cli/util.php --install
/tmp/php74bin/php server/admin/tool/phpunit/cli/util.php --buildconfig

This is the practical escape hatch when the wrapper logic itself is the problem.

Keep the workaround temporary and explicit

This is a legacy-tooling compatibility technique, not a permanent platform design. Use it to keep an old codebase testable while you work, but do not confuse it with a long-term environment strategy.


Solin specializes in Moodle and Totara maintenance, legacy upgrade paths, and test tooling. Need help? Contact us.

Solin supports legacy Moodle and Totara estates, including test tooling, upgrade prep, and version-specific debugging. Need help? Contact us.

Contact us