src/Util/Composer.php
public static function ensureProjectBinDirInSystemPath(string $binDir)
    {
        $pathStr = 'PATH';
        if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
            $pathStr = 'Path';
        }

        if (!is_dir($binDir)) {
            return;
        }

        // add the bin dir to the PATH to make local binaries of deps usable in scripts
        $binDir = realpath($binDir);
        $hasBindDirInPath = preg_match(
            '{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}',
            $_SERVER[$pathStr]
        );

        if (!$hasBindDirInPath && isset($_SERVER[$pathStr])) {
            $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
            putenv($pathStr.'='.$_SERVER[$pathStr]);
        }
    }
public static function ensureProjectBinDirInSystemPath(string $binDir)
    {
        $pathStr = 'PATH';
        if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
            $pathStr = 'Path';
        }

        if (!is_dir($binDir)) {
            return;
        }

        // add the bin dir to the PATH to make local binaries of deps usable in scripts
        $binDir = realpath($binDir);
        $hasBindDirInPath = preg_match(
            '{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}',
            $_SERVER[$pathStr]
        );

        if (!$hasBindDirInPath && isset($_SERVER[$pathStr])) {
            $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
            putenv($pathStr.'='.$_SERVER[$pathStr]);
        }
    }
public static function ensureProjectBinDirInSystemPath ( string $ binDir ) { $ pathStr = 'PATH' ; if ( ! isset ( $ _SERVER [ $ pathStr ] ) && isset ( $ _SERVER [ 'Path' ] ) ) { $ pathStr = 'Path' ; } if ( ! is_dir ( $ binDir ) ) { return ; } // add the bin dir to the PATH to make local binaries of deps usable in scripts $ binDir = realpath ( $ binDir ) ; $ hasBindDirInPath = preg_match ( '{(^|' . PATH_SEPARATOR . ')' . preg_quote ( $ binDir ) . '($|' . PATH_SEPARATOR . ')}' , $ _SERVER [ $ pathStr ] ) ; if ( ! $ hasBindDirInPath && isset ( $ _SERVER [ $ pathStr ] ) ) { $ _SERVER [ $ pathStr ] = $ binDir . PATH_SEPARATOR . getenv ( $ pathStr ) ; putenv ( $ pathStr . '=' . $ _SERVER [ $ pathStr ] ) ; } }
Composer contains some logic to prepend the current bin dir to the system PATH.
To make sure this application works the same in CLI and Composer modus,
we'll have to ensure that the bin path is always prefixed.

@see https://github.com/composer/composer/blob/1.1/src/Composer/EventDispatcher/EventDispatcher.php#L147-L160
Composer contains some logic to prepend the current bin dir to the system PATH . To make sure this application works the same in CLI and Composer modus we ll have to ensure that the bin path is always prefixed .