Skip to content

command.php: PHP_BINDIR fails on Magento Cloud - should be configurable via .env #924

@constantinospan

Description

@constantinospan

Preconditions

  1. Magento 2.4.7 on Adobe Commerce Cloud
  2. MFTF 4.7.5
  3. Running tests from local against cloud environment
  4. Tests use <magentoCLI> actions

Steps to reproduce

  1. Deploy to Adobe Commerce Cloud
  2. Run vendor/bin/mftf build:project
  3. Run vendor/bin/mftf doctor or any test with <magentoCLI> action

Expected result

Magento CLI commands execute successfully via command.php endpoint.

Actual result

HTTP 403: "Given command not found valid in Magento CLI Command list."

Root cause: Line 22 in command.php:

$php = PHP_BINDIR ? PHP_BINDIR . '/php' : 'php';

On Magento Cloud, PHP_BINDIR points to /usr/bin/php which is an incompatible PHP version. The correct PHP 8.3 is available via php in PATH, but the code never falls back to it because PHP_BINDIR is always set.

This is similar to issue #216 (PHP-FPM), which was fixed in PR #217 by switching from PHP_BINARY to PHP_BINDIR. That fixed PHP-FPM but broke Magento Cloud.

Simple fix: Make the PHP binary configurable in .env:

 $php = $_ENV['MFTF_PHP_BINARY'] ?? (PHP_BINDIR ? PHP_BINDIR . '/php' : 'php');

Then users can set MFTF_PHP_BINARY=php in .env for cloud environments.

Currently, we have to manually edit the file after every build:project, which isn't sustainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions