private static void HandlePhpReleaseSelection() { Console.Write(" * Fetching currently supported PHP releases from the official php.net site... "); phpReleases = PHP.GetPhpReleases(); Console.WriteLine("OK."); Console.WriteLine(" * Currently, these supported PHP editions are available. Please choose which one"); Console.WriteLine(" you want to install!"); if (phpAlreadyInstalled) { Console.WriteLine(" ATTENTION! Immediately after the selection, the installer overwrites/updates"); Console.WriteLine(" the currently installed PHP/Composer in the %LOCALAPPDATA%/Programs directory!"); } selectedPhpRelease = Selector.ShowSelectorMenu(phpReleases.Keys.ToArray()); Console.WriteLine(" * Selected: " + selectedPhpRelease); }
private static void HandleInstallation() { Console.WriteLine(" * Stop PHP processes that conflicts with this installer... "); PHP.KillRunningPhpProcessesByLocation(defaultPhpLocation); Console.Write(" * Run Visual C++ Redistributable Installer... "); var proc = new Process { StartInfo = new ProcessStartInfo { FileName = "PhpComposerInstallerDownloads/vc_redist.exe", Arguments = "/install /passive /quiet /norestart /log vc_redist.log", UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; proc.Start(); proc.WaitForExit(); Console.WriteLine("OK."); Installer.CopyToLocalAppData(); Installer.AddToPathIfNecessary(); }
private static void HandlePriorCheck() { // 32 vagy 64 bit Console.WriteLine(" * Detected architecture: " + (Environment.Is64BitOperatingSystem ? "64 bit" : "32 bit")); // Jelenleg telepített verziók vizsgálata var phpLocations = OS.FindProgramLocations("php"); var composerLocations = OS.FindProgramLocations("composer"); // A telepítő útvonalai if (phpLocations.Contains(defaultPhpLocation) || File.Exists(defaultPhpLocation)) { Console.WriteLine(" * Currently installed PHP version: " + PHP.GetPhpVersionByLocation(defaultPhpLocation)); phpAlreadyInstalled = true; } if (composerLocations.Contains(defaultComposerLocation) || File.Exists(defaultComposerLocation)) { Console.WriteLine(" * Currently installed Composer version: " + Composer.GetComposerVersionByLocation(defaultComposerLocation)); composerAlreadyInstalled = true; } // Olyan globálisan is elérhető PHP-k és Composer-ek keresése, amiket nem ez a telepítő rakott fel // Ezek csak akkor érdekesek, ha benne vannak a Path-ban, mivel ütközést okoznak, és lehet, hogy ezek // kerülnek meghívásra, nem a telepített PHP. var foreignPhpLocations = OS.FindProgramLocations("php").Where( location => !location.Equals(defaultPhpLocation) ).ToList(); var foreignComposerLocations = OS.FindProgramLocations("composer").Where( location => !location.Equals(defaultComposerLocation) ).ToList(); if (foreignPhpLocations.Count > 0 || foreignComposerLocations.Count > 0) { Console.WriteLine(" * ATTENTION! The installer detected a PHP/Composer installation that is included in the PATH environment"); Console.WriteLine(" variable, but it was not installed by this installer. This installer also adds the installed PHP to the"); Console.WriteLine(" PATH, however if there are two PHPs in this environment variable at the same time, it leads to a conflict."); Console.WriteLine(" One possible solution to this problem may be to remove the paths listed below from the PATH variable, or"); Console.WriteLine(" rename the php.exe file in them to php7.4.exe/php8.0.exe or anything other than php.exe."); Console.WriteLine(" "); if (foreignPhpLocations.Count > 0) { Console.WriteLine(" Detected PHP installs:"); foreach (var phpLocation in foreignPhpLocations) { Console.WriteLine(" - " + phpLocation + " (" + PHP.GetPhpVersionByLocation(phpLocation) + ")"); } Console.WriteLine(" "); } if (foreignComposerLocations.Count > 0) { Console.WriteLine(" Detected Composer installs:"); foreach (var composerLocation in foreignComposerLocations) { Console.WriteLine(" - " + composerLocation + " (" + Composer.GetComposerVersionByLocation(composerLocation) + ")"); } Console.WriteLine(" "); } } else { Console.WriteLine(" * No problems found."); } }