mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🌐 Localized startup environment checks
This commit is contained in:
@ -26,49 +26,45 @@ class Startup {
|
|||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("which php").contains("/usr/local/bin/php"),
|
!Shell.user.pipe("which php").contains("/usr/local/bin/php"),
|
||||||
messageText: "PHP is not correctly installed",
|
messageText: "startup.errors.php_binary.title".localized,
|
||||||
informativeText: "You must install PHP via brew. Try running `which php` in Terminal, it should return `/usr/local/bin/php`. The app will not work correctly until you resolve this issue. (Usually `brew link php` resolves this issue.)",
|
informativeText: "startup.errors.php_binary_desc".localized,
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("ls /usr/local/opt | grep php").contains("php"),
|
!Shell.user.pipe("ls /usr/local/opt | grep php").contains("php"),
|
||||||
messageText: "PHP is not correctly installed",
|
messageText: "startup.errors.php_opt.title".localized,
|
||||||
informativeText: "PHP alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue. If you already have the `php` formula installed, you may need to run `brew install php` in order for PHP Monitor to detect this installation.",
|
informativeText: "startup.errors.php_opt.desc".localized,
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("which valet").contains("/usr/local/bin/valet"),
|
!Shell.user.pipe("which valet").contains("/usr/local/bin/valet"),
|
||||||
messageText: "Laravel Valet is not correctly installed",
|
messageText: "startup.errors.valet_executable.title".localized,
|
||||||
informativeText: "You must install Valet with composer. Try running `which valet` in Terminal, it should return `/usr/local/bin/valet`. The app will not work correctly until you resolve this issue.",
|
informativeText: "startup.errors.valet_executable.desc".localized,
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("cat /private/etc/sudoers.d/brew").contains("/usr/local/bin/brew"),
|
!Shell.user.pipe("cat /private/etc/sudoers.d/brew").contains("/usr/local/bin/brew"),
|
||||||
messageText: "Brew has not been added to sudoers.d",
|
messageText: "startup.errors.sudoers_brew.title".localized,
|
||||||
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.",
|
informativeText: "startup.errors.sudoers_brew.desc".localized,
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
!Shell.user.pipe("cat /private/etc/sudoers.d/valet").contains("/usr/local/bin/valet"),
|
!Shell.user.pipe("cat /private/etc/sudoers.d/valet").contains("/usr/local/bin/valet"),
|
||||||
messageText: "Valet has not been added to sudoers.d",
|
messageText: "startup.errors.sudoers_valet.title".localized,
|
||||||
informativeText: "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.",
|
informativeText: "startup.errors.sudoers_valet.desc".localized,
|
||||||
breaking: true
|
breaking: true
|
||||||
)
|
)
|
||||||
|
|
||||||
let services = Shell.user.pipe("brew services list | grep php")
|
let services = Shell.user.pipe("brew services list | grep php")
|
||||||
self.performEnvironmentCheck(
|
self.performEnvironmentCheck(
|
||||||
(services.countInstances(of: "started") > 1),
|
(services.countInstances(of: "started") > 1),
|
||||||
messageText: "Multiple PHP services are active",
|
messageText: "startup.errors.services.title".localized,
|
||||||
informativeText: "This can cause php-fpm to serve a more recent version of PHP than the one you'd like to see active. Please terminate all extra PHP processes." +
|
informativeText: "startup.errors.services.desc".localized,
|
||||||
"\n\nThe easiest solution is to choose the option 'Force load latest PHP version' in the menu bar." +
|
breaking: false
|
||||||
"\n\nAlternatively, you can fix this manually. You can do this by running `brew services list` and running `sudo brew services stop php@7.3` (and use the version that applies)." +
|
|
||||||
"\n\nPHP Monitor usually handles the starting and stopping of these services, so once the correct version is the only PHP version running you should not have any issues. It is recommended to restart PHP Monitor once you have resolved this issue." +
|
|
||||||
"\n\nFor more information about this issue, please see the README.md file in the repository on GitHub.",
|
|
||||||
breaking: false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!self.failed) {
|
if (!self.failed) {
|
||||||
@ -99,7 +95,7 @@ class Startup {
|
|||||||
/**
|
/**
|
||||||
* Perform an environment check. Will cause the application to terminate, if `breaking` is set to true.
|
* Perform an environment check. Will cause the application to terminate, if `breaking` is set to true.
|
||||||
*
|
*
|
||||||
* - Parameter condition: Condition to check for
|
* - Parameter condition: Fail condition to check for; if this returns `true`, the alert will be shown
|
||||||
* - Parameter messageText: Short description of what is wrong
|
* - Parameter messageText: Short description of what is wrong
|
||||||
* - Parameter informativeText: Expanded description of the environment check that failed
|
* - Parameter informativeText: Expanded description of the environment check that failed
|
||||||
* - Parameter breaking: If the application should terminate afterwards
|
* - Parameter breaking: If the application should terminate afterwards
|
||||||
|
@ -54,3 +54,29 @@
|
|||||||
"alert.cannot_start.info" = "The issue you were just notified about is keeping PHP Monitor from functioning correctly. Please fix the issue and restart PHP Monitor. After clicking on OK, PHP Monitor will close.\n\nIf you have fixed the issue (or don't remember what the exact issue is) you can click on Retry, which will have PHP Monitor retry the startup checks.";
|
"alert.cannot_start.info" = "The issue you were just notified about is keeping PHP Monitor from functioning correctly. Please fix the issue and restart PHP Monitor. After clicking on OK, PHP Monitor will close.\n\nIf you have fixed the issue (or don't remember what the exact issue is) you can click on Retry, which will have PHP Monitor retry the startup checks.";
|
||||||
"alert.cannot_start.close" = "Close";
|
"alert.cannot_start.close" = "Close";
|
||||||
"alert.cannot_start.retry" = "Retry";
|
"alert.cannot_start.retry" = "Retry";
|
||||||
|
|
||||||
|
// STARTUP
|
||||||
|
|
||||||
|
/// 1. PHP binary not found
|
||||||
|
"startup.errors.php_binary.title" = "PHP is not correctly installed";
|
||||||
|
"startup.errors.php_binary_desc" = "You must install PHP via brew. Try running `which php` in Terminal, it should return `/usr/local/bin/php`. The app will not work correctly until you resolve this issue. (Usually `brew link php` resolves this issue.)";
|
||||||
|
|
||||||
|
/// 2. PHP not found in /usr/local/opt
|
||||||
|
"startup.errors.php_opt.title" = "PHP is not correctly installed";
|
||||||
|
"startup.errors.php_opt.desc" = "PHP alias was not found in `/usr/local/opt`. The app will not work correctly until you resolve this issue. If you already have the `php` formula installed, you may need to run `brew install php` in order for PHP Monitor to detect this installation.";
|
||||||
|
|
||||||
|
/// 3. Valet not installed
|
||||||
|
"startup.errors.valet_executable.title" = "Laravel Valet is not correctly installed";
|
||||||
|
"startup.errors.valet_executable.desc" = "You must install Valet with composer. Try running `which valet` in Terminal, it should return `/usr/local/bin/valet`. The app will not work correctly until you resolve this issue.";
|
||||||
|
|
||||||
|
/// 4. Brew & sudoers
|
||||||
|
"startup.errors.sudoers_brew.title" = "Brew has not been added to sudoers.d";
|
||||||
|
"startup.errors.sudoers_brew.desc" = "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.";
|
||||||
|
|
||||||
|
/// 5. Valet & sudoers
|
||||||
|
"startup.errors.sudoers_valet.title" = "Valet has not been added to sudoers.d";
|
||||||
|
"startup.errors.sudoers_valet.desc" = "You must run `sudo valet trust` to ensure Valet can start and stop services without having to use sudo every time. The app will not work correctly until you resolve this issue.";
|
||||||
|
|
||||||
|
/// 6. Multiple services active
|
||||||
|
"startup.errors.services.title" = "Multiple PHP services are active";
|
||||||
|
"startup.errors.services.desc" = "This can cause php-fpm to serve a more recent version of PHP than the one you'd like to see active. Please terminate all extra PHP processes.\n\nThe easiest solution is to choose the option 'Force load latest PHP version' in the menu bar.\n\nAlternatively, you can fix this manually. You can do this by running `brew services list` and running `sudo brew services stop php@7.3` (and use the version that applies).\n\nPHP Monitor usually handles the starting and stopping of these services, so once the correct version is the only PHP version running you should not have any issues. It is recommended to restart PHP Monitor once you have resolved this issue.\n\nFor more information about this issue, please see the README.md file in the repository on GitHub.";
|
||||||
|
Reference in New Issue
Block a user