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

🏗 Conditional PHP 5.6 support

This commit is contained in:
2022-03-14 21:31:30 +01:00
parent e21c2168ea
commit 26badc759e
2 changed files with 20 additions and 4 deletions

View File

@ -124,6 +124,12 @@ class PhpEnv {
) -> [String] { ) -> [String] {
var output : [String] = [] var output : [String] = []
var supported = Constants.SupportedPhpVersions
if !Valet.enabled(feature: .supportForPhp56) {
supported.removeAll { $0 == "5.6" }
}
versions.filter { (version) -> Bool in versions.filter { (version) -> Bool in
// Omit everything that doesn't start with php@ // Omit everything that doesn't start with php@
// (e.g. something-php@8.0 won't be detected) // (e.g. something-php@8.0 won't be detected)
@ -133,7 +139,7 @@ class PhpEnv {
// Only append the version if it doesn't already exist (avoid dupes), // Only append the version if it doesn't already exist (avoid dupes),
// is supported and where the binary exists (avoids broken installs) // is supported and where the binary exists (avoids broken installs)
if !output.contains(version) if !output.contains(version)
&& Constants.SupportedPhpVersions.contains(version) && supported.contains(version)
&& (checkBinaries ? Filesystem.fileExists("\(Paths.optPath)/php@\(version)/bin/php") : true) && (checkBinaries ? Filesystem.fileExists("\(Paths.optPath)/php@\(version)/bin/php") : true)
{ {
output.append(version) output.append(version)

View File

@ -11,7 +11,8 @@ import Foundation
class Valet { class Valet {
enum FeatureFlag { enum FeatureFlag {
case isolatedSites case isolatedSites,
supportForPhp56
} }
static let shared = Valet() static let shared = Valet()
@ -37,6 +38,13 @@ class Valet {
self.sites = [] self.sites = []
} }
/**
Check if a particular feature is enabled.
*/
public static func enabled(feature: FeatureFlag) -> Bool {
return self.shared.features.contains(feature)
}
/** /**
We don't want to load the initial config.json file as soon as the class is initialised. We don't want to load the initial config.json file as soon as the class is initialised.
Instead, we'll defer the loading of the configuration file once the initial app checks Instead, we'll defer the loading of the configuration file once the initial app checks
@ -91,9 +99,11 @@ class Valet {
*/ */
public func validateVersion() -> Void { public func validateVersion() -> Void {
if version.versionCompare("3.0") == .orderedAscending { if version.versionCompare("3.0") == .orderedAscending {
Log.warn("This version of Valet does not support isolation yet. Disabling isolation checks.") Log.info("This version of Valet does not support isolation yet. Disabling isolation checks.")
self.features.append(.supportForPhp56)
} else { } else {
self.features.append(FeatureFlag.isolatedSites) Log.info("This version of Valet does not support PHP 5.6.")
self.features.append(.isolatedSites)
} }
if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending { if version.versionCompare(Constants.MinimumRecommendedValetVersion) == .orderedAscending {