1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-08 04:20:07 +02:00

🔀 Merge bugfixes from 5.2 into 5.3

This commit is contained in:
2022-04-23 12:25:18 +02:00
7 changed files with 29 additions and 14 deletions

View File

@ -11,20 +11,24 @@ import XCTest
class PhpVersionNumberTest: XCTestCase { class PhpVersionNumberTest: XCTestCase {
func testCanDeconstructPhpVersion() throws { func testCanDeconstructPhpVersion() throws {
XCTAssertEqual(
try! PhpVersionNumber.parse("PHP 8.2.0-dev"),
PhpVersionNumber(major: 8, minor: 2, patch: 0)
)
XCTAssertEqual( XCTAssertEqual(
try! PhpVersionNumber.parse("PHP 8.1.0RC5-dev"), try! PhpVersionNumber.parse("PHP 8.1.0RC5-dev"),
PhpVersionNumber(major: 8, minor: 1, patch: 0) PhpVersionNumber(major: 8, minor: 1, patch: 0)
) )
XCTAssertEqual( XCTAssertEqual(
PhpVersionNumber.make(from: "8.0.11"), try! PhpVersionNumber.parse("8.0.11"),
PhpVersionNumber(major: 8, minor: 0, patch: 11) PhpVersionNumber(major: 8, minor: 0, patch: 11)
) )
XCTAssertEqual( XCTAssertEqual(
PhpVersionNumber.make(from: "7.4.2"), try! PhpVersionNumber.parse("7.4.2"),
PhpVersionNumber(major: 7, minor: 4, patch: 2) PhpVersionNumber(major: 7, minor: 4, patch: 2)
) )
XCTAssertEqual( XCTAssertEqual(
PhpVersionNumber.make(from: "7.4"), try! PhpVersionNumber.parse("7.4"),
PhpVersionNumber(major: 7, minor: 4, patch: nil) PhpVersionNumber(major: 7, minor: 4, patch: nil)
) )
XCTAssertEqual( XCTAssertEqual(

View File

@ -11,7 +11,7 @@ import Foundation
class VersionExtractor { class VersionExtractor {
/** /**
This attempts to extract the version number from the command line output of Valet. This attempts to extract the version number from any given string.
*/ */
public static func from(_ string: String) -> String? { public static func from(_ string: String) -> String? {
do { do {

View File

@ -13,7 +13,7 @@ public struct PhpVersionNumberCollection: Equatable {
public static func make(from versions: [String]) -> Self { public static func make(from versions: [String]) -> Self {
return PhpVersionNumberCollection( return PhpVersionNumberCollection(
versions: versions.map { PhpVersionNumber.make(from: $0)! } versions: versions.map { try! PhpVersionNumber.parse($0) }
) )
} }

View File

@ -71,6 +71,10 @@ class InternalSwitcher: PhpSwitcher {
let existing = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf")! let existing = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf")!
let new = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf.disabled-by-phpmon")! let new = URL(string: "file://\(Paths.etcPath)/php/\(version)/php-fpm.d/www.conf.disabled-by-phpmon")!
do { do {
if (FileManager.default.fileExists(atPath: new.path)) {
Log.info("A moved `www.conf.disabled-by-phpmon` file was found for PHP \(version), cleaning up so the newer `www.conf` can be moved again.")
try FileManager.default.removeItem(at: new)
}
try FileManager.default.moveItem(at: existing, to: new) try FileManager.default.moveItem(at: existing, to: new)
Log.info("Success: A default `www.conf` file was disabled for PHP \(version).") Log.info("Success: A default `www.conf` file was disabled for PHP \(version).")
} catch { } catch {

View File

@ -29,8 +29,18 @@ extension MainMenu {
When the environment is all clear and the app can run, let's go. When the environment is all clear and the app can run, let's go.
*/ */
private func onEnvironmentPass() { private func onEnvironmentPass() {
// Attempt to find out more info about Valet
if Valet.shared.version != nil {
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)")
}
// Validate the version (this will enforce which versions of PHP are supported)
Valet.shared.validateVersion()
// Actually detect the PHP versions
PhpEnv.detectPhpVersions() PhpEnv.detectPhpVersions()
// Check for an alias conflict
if HomebrewDiagnostics.hasAliasConflict() { if HomebrewDiagnostics.hasAliasConflict() {
DispatchQueue.main.async { DispatchQueue.main.async {
BetterAlert() BetterAlert()
@ -71,12 +81,7 @@ extension MainMenu {
// Load the global hotkey // Load the global hotkey
App.shared.loadGlobalHotkey() App.shared.loadGlobalHotkey()
// Attempt to find out more info about Valet // Preload sites
if Valet.shared.version != nil {
Log.info("PHP Monitor has extracted the version number of Valet: \(Valet.shared.version!)")
}
Valet.shared.validateVersion()
Valet.shared.startPreloadingSites() Valet.shared.startPreloadingSites()
// A non-default TLD is not officially supported since Valet 3.2.x // A non-default TLD is not officially supported since Valet 3.2.x

View File

@ -24,7 +24,8 @@ extension ActivePhpInstallation {
BetterAlert() BetterAlert()
.withInformation( .withInformation(
title: "alert.php_fpm_broken.title".localized, title: "alert.php_fpm_broken.title".localized,
subtitle: "alert.php_fpm_broken.info".localized subtitle: "alert.php_fpm_broken.info".localized,
description: "alert.php_fpm_broken.description".localized
) )
.withPrimary(text: "OK") .withPrimary(text: "OK")
.show() .show()

View File

@ -286,8 +286,9 @@ problem manually, using your own Terminal app (this just shows you the output)."
"alert.fix_homebrew_permissions_done.desc" = "When you are done with Homebrew (after running `brew upgrade`, for example) you should restart PHP Monitor and select \"Restart All Services\" if you want Valet to work again. It is always recommended to restart PHP Monitor whenever you upgrade PHP versions with `brew upgrade`, or things might break."; "alert.fix_homebrew_permissions_done.desc" = "When you are done with Homebrew (after running `brew upgrade`, for example) you should restart PHP Monitor and select \"Restart All Services\" if you want Valet to work again. It is always recommended to restart PHP Monitor whenever you upgrade PHP versions with `brew upgrade`, or things might break.";
// PHP FPM Broken // PHP FPM Broken
"alert.php_fpm_broken.title" = "PHP-FPM configuration is incorrect"; "alert.php_fpm_broken.title" = "Your PHP-FPM configuration is not pointing at the Valet socket!";
"alert.php_fpm_broken.info" = "PHP Monitor has determined that there are issues with your PHP-FPM config: it's not pointing to the Valet socket. This will result in 502 Bad Gateway if you visit websites linked via Valet.\n\nYou can usually fix this by running\n`valet install`, which updates your\n PHP-FPM configuration."; "alert.php_fpm_broken.info" = "PHP Monitor has determined that there are issues with your PHP-FPM config. This will result in '502 Bad Gateway' responses if you visit websites linked via Valet.";
"alert.php_fpm_broken.description" = "If it's been a while, you can usually fix this by running `valet install`, which updates your PHP-FPM configuration.\n\nIf you are seeing this message and you are trying to run a pre-release version of PHP, it is possible that Valet does not support this pre-release version of PHP yet.\n\nIf that is the case, you can try the following workaround: edit the file at `~/.composer/vendor/laravel/valet/cli/Valet/Brew.php` and add e.g. `php@8.2` to the `SUPPORTED_PHP_VERSIONS` array. After editing the file, try running `valet install`. (This will, if all goes well, set up all the required Valet configuration files.)";
// PHP Monitor Cannot Start // PHP Monitor Cannot Start
"alert.cannot_start.title" = "PHP Monitor cannot start due to a configuration problem"; "alert.cannot_start.title" = "PHP Monitor cannot start due to a configuration problem";