Skip to content

Commit b82f577

Browse files
author
Walter Francisco Núñez Cruz
committed
Add previous update to version 1.0.2
Add previous update to version 1.0.2
1 parent 3a1e8e4 commit b82f577

File tree

15 files changed

+902
-397
lines changed

15 files changed

+902
-397
lines changed

CHANGELOG.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ Todas las modificaciones notables en el proyecto PHP Switcher C# serán document
1111
- Información de tooltip para versiones instaladas y disponibles
1212
- Contador de versiones instaladas y disponibles en las pestañas correspondientes
1313
- Método `GetActiveVersion()` en la clase AppConfig para obtener la versión activa
14+
- Implementación mejorada de iconos de aplicación y logo en la interfaz de usuario
1415

1516
### Cambiado
1617
- Mejora en el manejo de nulabilidad en todo el código para reducir advertencias de compilación
1718
- Mejora en la visualización de versiones instaladas y disponibles con indicadores visuales
1819
- Proceso de inicialización actualizado para incluir sincronización de versiones instaladas
20+
- Reposicionamiento del logo PHP en el splash screen para evitar solapamiento con el título
21+
- Optimización del tamaño del logo PHP en el splash screen para mejor visualización
1922

2023
### Corregido
2124
- Problema de sincronización entre versiones PHP instaladas en el sistema de archivos y la configuración
2225
- Advertencias de nulabilidad en la compilación
2326
- Manejo mejorado de referencias potencialmente nulas en el código
27+
- Carga correcta del icono de la aplicación en todas las ventanas y en la barra de tareas
28+
- Visualización mejorada del logo PHP en el splash screen
2429

2530
## [1.0.0] - 2024-06-01
2631

@@ -51,16 +56,25 @@ Todas las modificaciones notables en el proyecto PHP Switcher C# serán document
5156
- Verificación más robusta de privilegios de administrador
5257
- Mejor gestión de enlaces simbólicos para activación de versiones PHP
5358

54-
## Pendiente para Futuras Versiones
55-
- Integración con servidores web (IIS, Apache)
56-
- Gestión de extensiones PHP
57-
- Optimización de rendimiento de descarga
58-
- Aplicación ejecutable independiente
59-
- Selección de espejos de descarga
60-
- Descargas paralelas
61-
- Configuración PHP avanzada
62-
- Mejoras en la gestión de iconos de barra de tareas
63-
- Implementación de datos de aplicación persistentes
64-
- Soporte para múltiples idiomas
65-
- Mejoras de accesibilidad
66-
- Sistema de actualizaciones automáticas
59+
## [1.0.2] - 2024-06-13
60+
61+
### Añadido
62+
- Generación de ejecutable independiente (self-contained) que incluye todas las dependencias de .NET
63+
- Creación de instalador MSI utilizando WiX Toolset
64+
- Documentación actualizada con instrucciones para compilación y distribución
65+
- Soporte mejorado para versiones de PHP anteriores a 7.4, incluyendo PHP 5.x y 6.x
66+
67+
### Cambiado
68+
- Mejora en el proceso de compilación para incluir todos los recursos necesarios
69+
- Optimización del tamaño del ejecutable final
70+
- Actualización de la expresión regular para detectar versiones de PHP más antiguas
71+
- Mejora en la lógica de procesamiento para manejar versiones x86 cuando no hay versiones x64 disponibles
72+
73+
### Corregido
74+
- Problema con la detección de la versión PHP 7.4.33 y otras versiones específicas
75+
- Uso exclusivo de la URL de archivos para obtener todas las versiones de PHP disponibles
76+
- Expresión regular mejorada para capturar correctamente todos los formatos de nombres de archivo
77+
- Simplificación del proceso de determinación de URL de descarga
78+
79+
## Estado del Proyecto
80+
El desarrollo de PHP Switcher se ha completado satisfactoriamente. Todas las características planeadas han sido implementadas y el proyecto se considera finalizado en su estado actual. La aplicación está lista para ser distribuida a los usuarios finales mediante el instalador MSI o el ejecutable independiente.

Forms/MainForm.cs

Lines changed: 154 additions & 54 deletions
Large diffs are not rendered by default.

Forms/SplashForm.cs

Lines changed: 155 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,37 @@ public SplashForm()
2121
_config = ConfigService.LoadConfiguration();
2222

2323
// Set version label
24-
versionLabel.Text = "v1.0.1";
24+
versionLabel.Text = "v1.0.2";
25+
26+
// Set application icon
27+
try
28+
{
29+
this.Icon = PhpSwitcher.Resources.AppResources.GetApplicationIcon();
30+
LogService.Log("Application icon loaded successfully", LogLevel.DEBUG);
31+
}
32+
catch (Exception ex)
33+
{
34+
LogService.Log($"Failed to load application icon: {ex.Message}", LogLevel.ERROR);
35+
}
36+
37+
// Set PHP logo
38+
try
39+
{
40+
var phpLogo = PhpSwitcher.Resources.AppResources.GetPhpLogo();
41+
if (phpLogo != null)
42+
{
43+
logoPictureBox.Image = phpLogo;
44+
LogService.Log("PHP logo loaded successfully", LogLevel.DEBUG);
45+
}
46+
else
47+
{
48+
LogService.Log("PHP logo not found", LogLevel.WARNING);
49+
}
50+
}
51+
catch (Exception ex)
52+
{
53+
LogService.Log($"Failed to load PHP logo: {ex.Message}", LogLevel.ERROR);
54+
}
2555

2656
// Start initialization after a short delay
2757
var timer = new System.Windows.Forms.Timer
@@ -137,55 +167,120 @@ private async Task PerformInitializationAsync()
137167
SynchronizeInstalledVersions();
138168

139169
// Step 4: Fetch available PHP versions
140-
statusLabel.Text = "Searching for Official PHP package on php.net archives...";
170+
statusLabel.Text = "Checking for PHP versions...";
141171
progressBar.Value = 60;
142172
Refresh();
143-
LogService.Log("Fetching available PHP versions from windows.php.net...", LogLevel.DEBUG);
173+
LogService.Log("Checking for available PHP versions...", LogLevel.DEBUG);
144174

145175
// Check if we need to update the PHP versions list
146-
bool updateNeeded = true;
176+
bool updateNeeded = false;
147177

148178
// In the final release, we should only update once a week
149179
if (_config.LastUpdated.HasValue)
150180
{
151181
var daysSinceUpdate = (DateTime.Now - _config.LastUpdated.Value).Days;
152182

153-
// For development, always update (comment out this condition in final release)
154-
// updateNeeded = daysSinceUpdate >= 7;
183+
// Only update if it's been more than 7 days since the last update
184+
updateNeeded = daysSinceUpdate >= 7;
155185

156186
LogService.Log($"Last update was {daysSinceUpdate} days ago. Update needed: {updateNeeded}", LogLevel.DEBUG);
157187
}
188+
else
189+
{
190+
// If we've never updated before, we need to update
191+
updateNeeded = true;
192+
LogService.Log("No previous update found. Update needed.", LogLevel.DEBUG);
193+
}
158194

195+
// Check if we have cached versions available
196+
bool hasCachedVersions = _config.AvailableVersions != null && _config.AvailableVersions.Count > 0;
197+
198+
if (hasCachedVersions)
199+
{
200+
LogService.Log($"Found {_config.AvailableVersions.Count} cached PHP versions.", LogLevel.DEBUG);
201+
statusLabel.Text = "Using cached PHP versions...";
202+
Refresh();
203+
}
204+
205+
// If we need to update and we're online, start a background task to update the versions
159206
if (updateNeeded)
160207
{
161-
try
208+
// If we have cached versions, use them first and update in the background
209+
if (hasCachedVersions)
162210
{
163-
var phpVersions = await PhpVersionService.FetchAvailablePhpVersionsAsync();
211+
// Start a background task to update the versions
212+
LogService.Log("Starting background update of PHP versions...", LogLevel.DEBUG);
213+
statusLabel.Text = "Starting background update of PHP versions...";
214+
Refresh();
164215

165-
if (phpVersions != null && phpVersions.Count > 0)
216+
// Start the update in a background task
217+
_config.IsBackgroundUpdateInProgress = true;
218+
Task.Run(async () => {
219+
try
220+
{
221+
LogService.Log("Background update of PHP versions started.", LogLevel.DEBUG);
222+
var phpVersions = await PhpVersionService.FetchAvailablePhpVersionsAsync();
223+
224+
if (phpVersions != null && phpVersions.Count > 0)
225+
{
226+
// Update configuration with available versions
227+
_config.AvailableVersions = phpVersions;
228+
_config.LastUpdated = DateTime.Now;
229+
ConfigService.SaveConfiguration(_config);
230+
231+
LogService.Log($"Background update complete. Found {phpVersions.Count} unique PHP versions.", LogLevel.DEBUG);
232+
}
233+
else
234+
{
235+
LogService.Log("Background update failed to fetch PHP versions or no versions found.", LogLevel.WARNING);
236+
}
237+
}
238+
catch (Exception ex)
239+
{
240+
LogService.Log($"Error in background update of PHP versions: {ex.Message}", LogLevel.ERROR);
241+
}
242+
finally
243+
{
244+
_config.IsBackgroundUpdateInProgress = false;
245+
}
246+
});
247+
}
248+
else
249+
{
250+
// If we don't have cached versions, we need to wait for the update
251+
statusLabel.Text = "Fetching PHP versions from windows.php.net...";
252+
Refresh();
253+
LogService.Log("Fetching PHP versions from windows.php.net...", LogLevel.DEBUG);
254+
255+
try
166256
{
167-
// Update configuration with available versions
168-
_config.AvailableVersions = phpVersions;
169-
_config.LastUpdated = DateTime.Now;
170-
ConfigService.SaveConfiguration(_config);
257+
var phpVersions = await PhpVersionService.FetchAvailablePhpVersionsAsync();
171258

172-
LogService.Log($"Found {phpVersions.Count} unique PHP versions available for download.", LogLevel.DEBUG);
259+
if (phpVersions != null && phpVersions.Count > 0)
260+
{
261+
// Update configuration with available versions
262+
_config.AvailableVersions = phpVersions;
263+
_config.LastUpdated = DateTime.Now;
264+
ConfigService.SaveConfiguration(_config);
265+
266+
LogService.Log($"Found {phpVersions.Count} unique PHP versions available for download.", LogLevel.DEBUG);
267+
}
268+
else
269+
{
270+
LogService.Log("Failed to fetch PHP versions or no versions found.", LogLevel.WARNING);
271+
}
173272
}
174-
else
273+
catch (Exception ex)
175274
{
176-
LogService.Log("Failed to fetch PHP versions or no versions found.", LogLevel.WARNING);
275+
LogService.Log($"Error fetching PHP versions: {ex.Message}", LogLevel.ERROR);
276+
// Continue even if this fails - we can try again later
277+
LogService.Log("Warning: Failed to fetch PHP versions. Will try again later.", LogLevel.WARNING);
177278
}
178279
}
179-
catch (Exception ex)
180-
{
181-
LogService.Log($"Error fetching PHP versions: {ex.Message}", LogLevel.ERROR);
182-
// Continue even if this fails - we can try again later
183-
LogService.Log("Warning: Failed to fetch PHP versions. Will try again later.", LogLevel.WARNING);
184-
}
185280
}
186281
else
187282
{
188-
LogService.Log($"Using cached PHP versions from last update on {_config.LastUpdated}", LogLevel.WARNING);
283+
LogService.Log($"Using cached PHP versions from last update on {_config.LastUpdated}", LogLevel.DEBUG);
189284
}
190285

191286
// Initialization completed successfully
@@ -290,9 +385,9 @@ private void InitializeComponent()
290385
//
291386
// logoPictureBox
292387
//
293-
this.logoPictureBox.Location = new System.Drawing.Point(218, 20);
388+
this.logoPictureBox.Location = new System.Drawing.Point(218, 130);
294389
this.logoPictureBox.Name = "logoPictureBox";
295-
this.logoPictureBox.Size = new System.Drawing.Size(64, 64);
390+
this.logoPictureBox.Size = new System.Drawing.Size(64, 40);
296391
this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
297392
this.logoPictureBox.TabIndex = 5;
298393
this.logoPictureBox.TabStop = false;
@@ -373,9 +468,39 @@ private void SynchronizeInstalledVersions()
373468
var version = match.Groups[1].Value;
374469
var isNTS = dirName.Contains("-nts");
375470

471+
// Determine if this is an x64 or x86 version
472+
bool isX64 = false;
473+
474+
// Check if php.exe is 64-bit
475+
try
476+
{
477+
var phpExePath = Path.Combine(dir, "php.exe");
478+
using (var stream = new FileStream(phpExePath, FileMode.Open, FileAccess.Read))
479+
{
480+
stream.Seek(0x3C, SeekOrigin.Begin);
481+
var peOffset = new byte[4];
482+
stream.Read(peOffset, 0, 4);
483+
var offset = BitConverter.ToInt32(peOffset, 0);
484+
485+
stream.Seek(offset + 4, SeekOrigin.Begin);
486+
var machineType = new byte[2];
487+
stream.Read(machineType, 0, 2);
488+
489+
// 0x8664 is the machine type for x64
490+
isX64 = BitConverter.ToUInt16(machineType, 0) == 0x8664;
491+
}
492+
493+
LogService.Log($"Detected PHP {version} as {(isX64 ? "x64" : "x86")} architecture", LogLevel.DEBUG);
494+
}
495+
catch (Exception ex)
496+
{
497+
LogService.Log($"Error determining architecture for PHP {version}: {ex.Message}. Assuming x86.", LogLevel.WARNING);
498+
isX64 = false;
499+
}
500+
376501
// Check if this version is already in the configuration
377502
var existingVersion = _config.InstalledVersions.FirstOrDefault(
378-
v => v.Version == version && v.IsNTS == isNTS);
503+
v => v.Version == version && v.IsNTS == isNTS && v.IsX64 == isX64);
379504

380505
if (existingVersion == null)
381506
{
@@ -384,6 +509,7 @@ private void SynchronizeInstalledVersions()
384509
{
385510
Version = version,
386511
IsNTS = isNTS,
512+
IsX64 = isX64,
387513
InstallPath = dir,
388514
InstallDate = File.GetCreationTime(dir),
389515
IsActive = (activePhpPath != null && activePhpPath.Equals(dir, StringComparison.OrdinalIgnoreCase))
@@ -392,23 +518,23 @@ private void SynchronizeInstalledVersions()
392518
_config.InstalledVersions.Add(newInstalledVersion);
393519
addedVersions++;
394520

395-
LogService.Log($"Added PHP {version} {(isNTS ? "(NTS)" : "(TS)")} to installed versions", LogLevel.DEBUG);
521+
LogService.Log($"Added PHP {version} {(isNTS ? "(NTS)" : "(TS)")} {(isX64 ? "(x64)" : "(x86)")} to installed versions", LogLevel.DEBUG);
396522
}
397523
else
398524
{
399525
// Update installation path and active status if needed
400526
if (existingVersion.InstallPath != dir)
401527
{
402528
existingVersion.InstallPath = dir;
403-
LogService.Log($"Updated path for PHP {version} {(isNTS ? "(NTS)" : "(TS)")}: {dir}", LogLevel.DEBUG);
529+
LogService.Log($"Updated path for PHP {version} {(isNTS ? "(NTS)" : "(TS)")} {(isX64 ? "(x64)" : "(x86)")}: {dir}", LogLevel.DEBUG);
404530
}
405531

406532
// Update active status based on symbolic link
407533
bool shouldBeActive = (activePhpPath != null && activePhpPath.Equals(dir, StringComparison.OrdinalIgnoreCase));
408534
if (existingVersion.IsActive != shouldBeActive)
409535
{
410536
existingVersion.IsActive = shouldBeActive;
411-
LogService.Log($"Updated active status for PHP {version} {(isNTS ? "(NTS)" : "(TS)")}: {shouldBeActive}", LogLevel.DEBUG);
537+
LogService.Log($"Updated active status for PHP {version} {(isNTS ? "(NTS)" : "(TS)")} {(isX64 ? "(x64)" : "(x86)")}: {shouldBeActive}", LogLevel.DEBUG);
412538
}
413539
}
414540
}

Installer/PhpSwitcher-1.0.2.wixpdb

10.9 KB
Binary file not shown.

Installer/PhpSwitcher.wixpdb

10.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)