69 {
70 $this->filesystem = new Filesystem();
71 $this->composer = new Composer();
72 $this->config = new Config();
73 $this->io = new NullIO();
74
75 $this->componentDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'component-installer-componentDir';
76 $this->vendorDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'component-installer-vendorDir';
77 $this->binDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'component-installer-binDir';
78
79 foreach (array($this->componentDir, $this->vendorDir, $this->binDir) as $dir) {
80 if (is_dir($dir)) {
81 $this->filesystem->removeDirectory($dir);
82 }
83 $this->filesystem->ensureDirectoryExists($dir);
84 }
85 $this->config->merge(array(
86 'config' => array(
87 'vendor-dir' => $this->vendorDir,
88 'component-dir' => $this->componentDir,
89 'bin-dir' => $this->binDir,
90 )
91 ));
92 $this->composer->setConfig($this->config);
93
94
95 $this->installationManager = new InstallationManager();
96 $this->installationManager->addInstaller(new LibraryInstaller($this->io, $this->composer));
97 $this->installationManager->addInstaller(new Installer($this->io, $this->composer));
98 $this->composer->setInstallationManager($this->installationManager);
99 }