public static Boolean MakeEnv(MYSQLHandler.DB db, DeployeSetting setting) { try { Console.WriteLine("Downloading environment..."); string urlAddress = "https://raw.githubusercontent.com/laravel/laravel/master/.env.example"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; if (String.IsNullOrWhiteSpace(response.CharacterSet)) { readStream = new StreamReader(receiveStream); } else { readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); } string data = readStream.ReadToEnd(); response.Close(); readStream.Close(); string envPath = Path.GetDirectoryName(setting.PROJECT) + @"\.env"; //delete env if exists if (File.Exists(envPath)) { File.Delete(envPath); } using (StreamWriter sw = File.CreateText(envPath)) { sw.WriteLine(data); } string text = File.ReadAllText(envPath); text = text.Replace("DB_DATABASE=laravel", "DB_DATABASE=" + db.db); text = text.Replace("DB_USERNAME=root", "DB_USERNAME="******"Succesfully created environment file."); } } catch (WebException e) { Console.WriteLine("Failed to connect, please check your connection."); return(false); } return(true); }
public bool InstallProject() { //meminta nama database while (!setting.isSettingCorrect()) { Setting(); } MYSQLHandler.DB database = new MYSQLHandler.DB(); while (!database.correct()) { Console.Write("Database Name : "); string db = Console.ReadLine().ToLower(); Console.WriteLine(); Console.Write("Database User : "******"Password : "******"Installing project....(this may take a while)"); string composerPath = Path.GetDirectoryName(setting.PROJECT) + @"\sl.cmd"; using (StreamWriter sw = File.CreateText(composerPath)) { sw.WriteLine("composer install"); } //check mysql is runing ProcessManager.SimpleProcessGenerator(composerPath, Path.GetDirectoryName(setting.PROJECT), ""); string key = "artisan key:generate"; ProcessManager.ProcessGenerator(setting.PHP, key, setting); string clear = "artisan config:clear"; ProcessManager.ProcessGenerator(setting.PHP, clear, setting); ProcessManager.ProcessGenerator(setting.PHP, key, setting); string arg = "artisan migrate:fresh --seed"; ProcessManager.ProcessGenerator(setting.PHP, arg, setting); Console.WriteLine("Instalation complete."); return(true); }