protected function execute(InputInterface $input, OutputInterface $output)
{
if (!class_exists('ZipArchive')) {
throw new RuntimeException('The Zip PHP extension is not installed. Please install it and try again.');
}
$this->verifyApplicationDoesntExist($directory = $input->getArgument('name') ? getcwd() . '/' . $input->getArgument('name') : getcwd());
$output->writeln('<info>Crafting application...</info>');
$version = $this->getVersion($input);
$this->download($zipFile = $this->makeFilename(), $version)->extract($zipFile, $directory)->cleanUp($zipFile);
$composer = $this->findComposer();
$commands = [$composer . ' install --no-scripts', $composer . ' run-script post-root-package-install', $composer . ' run-script post-install-cmd', $composer . ' run-script post-create-project-cmd'];
if ($input->getOption('no-ansi')) {
$commands = array_map(function ($value) {
return $value . ' --no-ansi';
}, $commands);
}
$process = new Process(implode(' && ', $commands), $directory, null, null, null);
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
$process->setTty(true);
}
$process->run(function ($type, $line) use($output) {
$output->write($line);
});
$output->writeln('<comment>Application ready! Build something amazing.</comment>');
}