diff --git a/app/Console/Commands/InstallApp.php b/app/Console/Commands/InstallApp.php index 5db128ad2..0984b190c 100644 --- a/app/Console/Commands/InstallApp.php +++ b/app/Console/Commands/InstallApp.php @@ -46,8 +46,6 @@ class InstallApp extends Command /** * Create a new command instance. - * - * @return void */ public function __construct(UserRepositoryInterface $repository = null) { @@ -92,9 +90,9 @@ public function handle() $this->line(''); $config = [ - 'db' => $this->getDatabaseInformation(), - 'app' => $this->getInstallInformation(), - 'mail' => $this->getEmailInformation(), + 'db' => $this->getDatabaseInformation(), + 'app' => $this->getInstallInformation(), + 'mail' => $this->getEmailInformation(), ]; $admin = $this->getAdminInformation(); @@ -127,14 +125,15 @@ public function handle() $this->line(''); $this->comment('5. (Optional) Setup logrotate, see "logrotate.conf"'); $this->line(''); - $this->comment('6. Visit ' . $config['app']['url'] . ' and login with the details you provided to get started'); + $this->comment('6. Visit '.$config['app']['url'].' and login with the details you provided to get started'); $this->line(''); } /** * Writes the configuration data to the config file. * - * @param array $input The config data to write + * @param array $input The config data to write + * * @return bool */ protected function writeEnvFile(array $input) @@ -142,7 +141,7 @@ protected function writeEnvFile(array $input) $this->info('Writing configuration file'); $this->line(''); - $path = base_path('.env'); + $path = base_path('.env'); $config = file_get_contents($path); // Move the socket value to the correct key @@ -153,7 +152,7 @@ protected function writeEnvFile(array $input) if (isset($input['app']['ssl'])) { foreach ($input['app']['ssl'] as $key => $value) { - $input['socket']['ssl_' . $key] = $value; + $input['socket']['ssl_'.$key] = $value; } unset($input['app']['ssl']); @@ -161,9 +160,9 @@ protected function writeEnvFile(array $input) foreach ($input as $section => $data) { foreach ($data as $key => $value) { - $env = strtoupper($section . '_' . $key); + $env = strtoupper($section.'_'.$key); - $config = preg_replace('/' . $env . '=(.*)/', $env . '=' . $value, $config); + $config = preg_replace('/'.$env.'=(.*)/', $env.'='.$value, $config); } } @@ -172,7 +171,7 @@ protected function writeEnvFile(array $input) foreach (['host', 'database', 'username', 'password'] as $key) { $key = strtoupper($key); - $config = preg_replace('/DB_' . $key . '=(.*)[\n]/', '', $config); + $config = preg_replace('/DB_'.$key.'=(.*)[\n]/', '', $config); } } @@ -181,7 +180,7 @@ protected function writeEnvFile(array $input) foreach (['host', 'port', 'username', 'password'] as $key) { $key = strtoupper($key); - $config = preg_replace('/MAIL_' . $key . '=(.*)[\n]/', '', $config); + $config = preg_replace('/MAIL_'.$key.'=(.*)[\n]/', '', $config); } } @@ -190,8 +189,6 @@ protected function writeEnvFile(array $input) /** * Calls the artisan key:generate to set the APP_KEY. - * - * @return void */ private function generateKey() { @@ -218,8 +215,7 @@ protected function generateJWTKey() * Calls the artisan migrate to set up the database * in development mode it also seeds the DB. * - * @param bool $seed Whether or not to seed the database - * @return void + * @param bool $seed Whether or not to seed the database */ protected function migrate($seed = false) { @@ -238,8 +234,6 @@ protected function migrate($seed = false) /** * Clears all Laravel caches. - * - * @return void */ protected function clearCaches() { @@ -252,8 +246,6 @@ protected function clearCaches() /** * Runs the artisan optimize commands. - * - * @return void */ protected function optimize() { @@ -293,15 +285,15 @@ private function getDatabaseInformation() $user = $this->ask('Username', 'deployer'); $pass = $this->secret('Password'); - $database['host'] = $host; + $database['host'] = $host; $database['database'] = $name; $database['username'] = $user; $database['password'] = $pass; - Config::set('database.connections.' . $type . '.host', $host); - Config::set('database.connections.' . $type . '.database', $name); - Config::set('database.connections.' . $type . '.username', $user); - Config::set('database.connections.' . $type . '.password', $pass); + Config::set('database.connections.'.$type.'.host', $host); + Config::set('database.connections.'.$type.'.database', $name); + Config::set('database.connections.'.$type.'.username', $user); + Config::set('database.connections.'.$type.'.password', $pass); } $connectionVerified = $this->verifyDatabaseDetails($database); @@ -334,13 +326,13 @@ private function getInstallInformation() return preg_replace('#/$#', '', $answer); }; - $url = $this->askAndValidate('Application URL ("http://deploy.app" for example)', [], $url_callback); + $url = $this->askAndValidate('Application URL ("http://deploy.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); + $region .= '/'.$this->choice('Timezone location', $locations, 0); } $socket = $this->askAndValidate('Socket URL', [], $url_callback, $url); @@ -375,11 +367,10 @@ private function getInstallInformation() $ssl = null; if (substr($socket, 0, 5) === 'https') { - $ssl = [ - 'key_file' => $this->askAndValidate('SSL key File', [], $path_callback), + '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), + 'ca_file' => $this->askAndValidate('SSL certificate authority file', [], $path_callback), ]; }; @@ -391,11 +382,11 @@ private function getInstallInformation() } return [ - 'url' => $url, + 'url' => $url, 'timezone' => $region, - 'socket' => $socket, - 'ssl' => $ssl, - 'locale' => $locale, + 'socket' => $socket, + 'ssl' => $ssl, + 'locale' => $locale, ]; } @@ -430,8 +421,8 @@ private function getEmailInformation() $user = $this->ask('Username'); $pass = $this->secret('Password'); - $email['host'] = $host; - $email['port'] = $port; + $email['host'] = $host; + $email['port'] = $port; $email['username'] = $user; $email['password'] = $pass; } @@ -450,9 +441,9 @@ private function getEmailInformation() return $answer; }, 'deployer@deploy.app'); - $email['from_name'] = $from_name; + $email['from_name'] = $from_name; $email['from_address'] = $from_address; - $email['driver'] = $driver; + $email['driver'] = $driver; // TODO: Attempt to connect? @@ -485,33 +476,34 @@ private function getAdminInformation() $password = $this->secret('Password'); // TODO: Should validate it is at least 6 characters return [ - 'name' => $name, - 'email' => $email_address, - 'password' => $password, + 'name' => $name, + 'email' => $email_address, + 'password' => $password, ]; } /** * Verifies that the database connection details are correct. * - * @param array $database The connection details + * @param array $database The connection details + * * @return bool */ private function verifyDatabaseDetails(array $database) { if ($database['type'] === 'sqlite') { - return touch(storage_path() . '/database.sqlite'); + return touch(storage_path().'/database.sqlite'); } try { $connection = new PDO( - $database['type'] . ':host=' . $database['host'] . ';dbname=' . $database['database'], + $database['type'].':host='.$database['host'].';dbname='.$database['database'], $database['username'], $database['password'], [ PDO::ATTR_PERSISTENT => false, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_TIMEOUT => 2, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_TIMEOUT => 2, ] ); @@ -574,7 +566,7 @@ private function checkRequirements() foreach ($required_extensions as $extension) { if (!extension_loaded($extension)) { - $this->error('Extension required: ' . $extension); + $this->error('Extension required: '.$extension); $errors = true; } } @@ -589,7 +581,7 @@ private function checkRequirements() foreach ($required_functions as $function) { if (!function_exists($function)) { - $this->error('Function required: ' . $function . '. Is it disabled in php.ini?'); + $this->error('Function required: '.$function.'. Is it disabled in php.ini?'); $errors = true; } } @@ -598,13 +590,13 @@ private function checkRequirements() $required_commands = ['ssh', 'ssh-keygen', 'git', 'scp']; foreach ($required_commands as $command) { - $process = new Process('which ' . $command); + $process = new Process('which '.$command); $process->setTimeout(null); $process->run(); if (!$process->isSuccessful()) { - $this->error('Program not found in path: ' . $command); + $this->error('Program not found in path: '.$command); $errors = true; } } @@ -617,7 +609,7 @@ private function checkRequirements() foreach ($writable as $path) { if (!is_writeable(base_path($path))) { - $this->error($path . ' is not writeable'); + $this->error($path.' is not writeable'); $errors = true; } } @@ -656,24 +648,26 @@ private function getDatabaseDrivers() private function getTimezoneRegions() { return [ - 'UTC' => DateTimeZone::UTC, - 'Africa' => DateTimeZone::AFRICA, - 'America' => DateTimeZone::AMERICA, + 'UTC' => DateTimeZone::UTC, + 'Africa' => DateTimeZone::AFRICA, + 'America' => DateTimeZone::AMERICA, 'Antarctica' => DateTimeZone::ANTARCTICA, - 'Asia' => DateTimeZone::ASIA, - 'Atlantic' => DateTimeZone::ATLANTIC, - 'Australia' => DateTimeZone::AUSTRALIA, - 'Europe' => DateTimeZone::EUROPE, - 'Indian' => DateTimeZone::INDIAN, - 'Pacific' => DateTimeZone::PACIFIC, + 'Asia' => DateTimeZone::ASIA, + 'Atlantic' => DateTimeZone::ATLANTIC, + 'Australia' => DateTimeZone::AUSTRALIA, + 'Europe' => DateTimeZone::EUROPE, + 'Indian' => DateTimeZone::INDIAN, + 'Pacific' => DateTimeZone::PACIFIC, ]; } /** * Gets a list of available locations in the supplied region. * - * @param int $region The region constant + * @param int $region The region constant + * * @return array + * * @see DateTimeZone */ private function getTimezoneLocations($region) @@ -707,9 +701,8 @@ private function getLocales() /** * A wrapper around symfony's formatter helper to output a block. * - * @param string|array $messages Messages to output - * @param string $type The type of message to output - * @return void + * @param string|array $messages Messages to output + * @param string $type The type of message to output */ protected function block($messages, $type = 'error') { @@ -734,8 +727,7 @@ protected function block($messages, $type = 'error') /** * Outputs a header block. * - * @param string $header The text to output - * @return void + * @param string $header The text to output */ protected function header($header) {