3 namespace Cli\Services;
9 public function __construct(
10 protected string $appDir
14 public function getProgram(): ProgramRunner
16 return (new ProgramRunner('composer', '/usr/local/bin/composer'))
19 ->withAdditionalPathLocation($this->appDir);
25 public function download(): void
27 $setupPath = $this->appDir . DIRECTORY_SEPARATOR . 'composer-setup.php';
28 $signature = file_get_contents('https://composer.github.io/installer.sig');
29 copy('https://getcomposer.org/installer', $setupPath);
30 $checksum = hash_file('sha384', $setupPath);
32 if ($signature !== $checksum) {
34 throw new Exception("Could not install composer, checksum validation failed.");
37 $status = (new ProgramRunner('php', '/usr/bin/php'))
38 ->runWithoutOutputCallbacks([
39 $setupPath, '--quiet',
40 "--install-dir={$this->appDir}",
41 "--filename=composer",
47 throw new Exception("Could not install composer, composer-setup script run failed.");