private function getInstallInformation()
{
$this->header('Installation details');
$regions = $this->getTimezoneRegions();
$locales = $this->getLocales();
$url_callback = function ($answer) {
$validator = Validator::make(['url' => $answer], ['url' => 'url']);
if (!$validator->passes()) {
throw new \RuntimeException($validator->errors()->first('url'));
}
return preg_replace('#/$#', '', $answer);
};
$url = $this->askAndValidate('Application URL ("http://deployer.app" for example)', [], $url_callback);
$region = $this->choice('Timezone region', array_keys($regions), 0);
if ($region !== 'UTC') {
$locations = $this->getTimezoneLocations($regions[$region]);
$region .= '/' . $this->choice('Timezone location', $locations, 0);
}
$socket = $this->askAndValidate('Socket URL', [], $url_callback, $url);
// If the URL doesn't have : in twice (the first is in the protocol, the second for the port)
if (substr_count($socket, ':') === 1) {
// Check if running on nginx, and if not then add it
$process = new Process('which nginx');
$process->setTimeout(null);
$process->run();
if (!$process->isSuccessful()) {
$socket .= ':6001';
}
}
$path_callback = function ($answer) {
$validator = Validator::make(['path' => $answer], ['path' => 'required']);
if (!$validator->passes()) {
throw new \RuntimeException($validator->errors()->first('path'));
}
if (!file_exists($answer)) {
throw new \RuntimeException('File does not exist');
}
return $answer;
};
$ssl = null;
if (substr($socket, 0, 5) === 'https') {
$ssl = ['key_file' => $this->askAndValidate('SSL key File', [], $path_callback), 'cert_file' => $this->askAndValidate('SSL certificate File', [], $path_callback), 'ca_file' => $this->askAndValidate('SSL certificate authority file', [], $path_callback)];
}
// If there is only 1 locale just use that
if (count($locales) === 1) {
$locale = $locales[0];
} else {
$default = array_search(Config::get('app.fallback_locale'), $locales, true);
$locale = $this->choice('Language', $locales, $default);
}
return ['url' => $url, 'timezone' => $region, 'socket' => $socket, 'ssl' => $ssl, 'locale' => $locale];
}