public function exec()

in lib/php/libsdk/SDK/Build/PGO/Abstracts/PHP.php [181:223]


	public function exec(string $php_cmd, string $args = NULL, array $extra_env = array()) : int
	{
		$env = $this->createEnv();
		$exe = $this->getExeFilename();
		$ini = $this->getIniFilename();

		$cert_path = getenv("PHP_SDK_ROOT_PATH") . "\\msys2\\usr\\ssl\\cert.pem";
		$ini .= " -d curl.cainfo=$cert_path";

		$spent_key = array();
		foreach ($env as $k0 => &$v0) {
			foreach ($extra_env as $k1 => $v1) {
				if (strtoupper($k0) == strtoupper($k1)) {
					/* XXX some more things could require extra handling. */
					if (strtoupper($k0) == "PATH") {
						$v0 = "$v1;$v0";
					} else {
						$v0 = $v1;
					}
					$spent_key[] = $k1;
					break;
				}
			}
		}

		foreach ($extra_env as $k => $v) {
			if (in_array($k, $spent_key)) {
				continue;
			}
			$env[$k] = $v;
		}

		$cmd = "$exe -n -c $ini " . ($args ? "$args " : "") . $php_cmd;

		$desc = array(
			0 => array("file", "php://stdin", "r"),
			1 => array("file", "php://stdout", "w"),
			2 => array("file", "php://stderr", "w")
		);
		$p = proc_open($cmd, $desc, $pipes, $this->getRootDir(), $env);

		return proc_close($p);
	}