Skip to content

Commit

Permalink
🐛 Restart PHP-FPM after managing extensions
Browse files Browse the repository at this point in the history
This is done to prevent issues like #292.
  • Loading branch information
nicoverbruggen committed Jun 28, 2024
1 parent 652878d commit a3226b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions phpmon/Common/Core/Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Actions {
await brew("services restart \(HomebrewFormulae.php)", sudo: HomebrewFormulae.php.elevated)
}

public static func restartPhpFpm(version: String) async {
let formula = (version == PhpEnvironments.brewPhpAlias) ? "php" : "php@\(version)"
await brew("services restart \(formula)", sudo: HomebrewFormulae.php.elevated)
}

public static func restartNginx() async {
await brew("services restart \(HomebrewFormulae.nginx)", sudo: HomebrewFormulae.nginx.elevated)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class InstallPhpExtensionCommand: BrewCommand {
// Reload and restart PHP versions
onProgress(.create(value: 0.95, title: self.getCommandTitle(), description: "phpman.steps.reloading".localized))

// Restart PHP-FPM
if let installed = self.installing.first {
await Actions.restartPhpFpm(version: installed.phpVersion)
}

// Check which version of PHP are now installed
await PhpEnvironments.detectPhpVersions()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class RemovePhpExtensionCommand: BrewCommand {

await PhpEnvironments.detectPhpVersions()

await Actions.restartPhpFpm(version: phpExtension.phpVersion)

await MainMenu.shared.refreshActiveInstallation()

onProgress(.create(value: 1, title: getCommandTitle(), description: "phpman.steps.success".localized))
Expand Down

0 comments on commit a3226b6

Please sign in to comment.