Skip to main content

Module binproxy

Module binproxy 

Source
Expand description

vendor/bin proxies: byte-for-byte port of BinaryInstaller::generateUnixyProxyCode (docs/reference/BinaryInstaller.php). Three shapes: PHP target with shebang (anti-shebang stream wrapper for PHP<8, special phpunit hack), bare PHP target, non-PHP target (sh proxy). Parity is held by the differential test against the proxies generated by Composer in the Laravel fixture (tests/fixtures_binproxy.rs).

Enums§

BinCompat
The resolved bin-compat: Full writes the .bat proxy in addition to the unixy proxy (BinaryInstaller::installFullBinaries), Proxy writes the unixy proxy alone (installUnixyProxyBinaries) — which is what Composer produces on plain Linux/macOS.

Functions§

install_binaries
Installs a package’s proxies (laid out in package_dir) into vendor/bin (0755), following the resolved BinCompat exactly as BinaryInstaller::installBinaries does: Full (bin-compat "full", or "auto" on Windows/WSL) goes through [install_full_binaries]; Proxy writes the unixy proxy alone. vivacity always writes proxies (never symlinks), which is Composer’s own proxy mode.
proxy_content
Generates the content of the proxy link (vendor/bin/) to the binary bin (absolute, inside vendor/ or outside it with composer/installers), reading the target’s header. Relative paths are those of BinaryInstaller::installUnixyProxyBinaries (findShortestPath from the proxy file).
resolve_bin_compat
Config::get('bin-compat') + the resolution in BinaryInstaller::installBinaries (2.10.3): the value comes from COMPOSER_BIN_COMPAT (?: in Config::get, so "" and "0" fall through) else config.bin-compat of the root composer.json else the global COMPOSER_HOME/config.json (Config::merge layers) else "auto", and resolves to Full iff it is "full", or "auto" on Windows or WSL (Platform::isWindows() || Platform::isWindowsSubsystemForLinux()).
resolve_bin_compat_with
Pure core of resolve_bin_compat, for tests: env is the COMPOSER_BIN_COMPAT override, global the config.bin-compat of the global config.json, windows_or_wsl the platform predicate. An unknown value is refused with Composer’s own message; the deprecated "symlink" is accepted and behaves like "proxy" (Composer deprecation- warns then takes the non-full branch — vivacity never symlinks anyway).
windows_binary_caller
BinaryInstaller::determineBinaryCaller: call for a .bat or .exe target (substr($bin, -4) — case-sensitive, and NOT .cmd); otherwise the shebang interpreter — everything after the last path segment, arguments included (#!/usr/bin/env php -dfoophp -dfoo); otherwise php.
windows_proxy_content
BinaryInstaller::generateWindowsProxyCode: a .bat whose target, for a php caller, is the NEIGHBOURING unixy proxy (%~dp0/<name> = basename($link, '.bat')) — the one that sets the $GLOBALS['_composer_*'] and includes the real binary. Any other caller (call for a real .bat/.exe target, a non-php shebang such as sh, or a shebang carrying arguments such as php -dfoo) targets the real binary via findShortestPath. Composer wraps that path in trim(ProcessExecutor::escape(...), '"\''), which is the bare path again for any path without embedded quotes — the simplification kept here. Verified byte-for-byte against native Composer 2.10.3 on the psr/log + monolog + nikic/php-parser fixture, and by real execution under a Windows PHP (tests/fixtures_binproxy.rs).