Skip to content

Commit

Permalink
Fix valet fix forcefully reinstalling and relinking the default PHP v…
Browse files Browse the repository at this point in the history
…ersion (#537)
  • Loading branch information
Neodork authored Oct 2, 2020
1 parent 1ed174b commit 3db9d71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 12 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ steps:
displayName: '[INSTALL] Brew update'
# For the Valet+ CI/CD remove the default brew PHP. Instead use valet-php.
# An enduser might choose to keep his/her default brew PHP installation.
# On a local installation one might choose to keep his/her default brew PHP installation.
- script: |
brew uninstall php
displayName: '[INSTALL] Brew uninstall php'
Expand Down Expand Up @@ -184,3 +184,14 @@ steps:
- script: |
./valet memcache uninstall
displayName: '[MEMCACHED] uninstall'
# Extensions of commonly run commands, generally not hit or checked by the installation instructions.

# Chown the default PHP version to ensure deletion is possible.
# If we don't chown we'll get an permission error from the CI/CD.
# On local installations the printed instructions can be followed
# to manually remove the Cellar files.
- script: |
sudo chmod -R 777 /usr/local/Cellar/[email protected]
./valet fix --reinstall
displayName: '[INSTALL] Valet fix --reinstall'
21 changes: 16 additions & 5 deletions cli/Valet/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,22 @@ public function writePerformanceConfiguration()
public function fix($reinstall)
{
// If the current php is not 7.2, link 7.2.
info('Installing and linking new PHP homebrew/core version.');
output($this->cli->runAsUser('brew uninstall ' . self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION]));
output($this->cli->runAsUser('brew install ' . self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION]));
output($this->cli->runAsUser('brew unlink ' . self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION]));
output($this->cli->runAsUser('brew link ' . self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION] . ' --force --overwrite'));
info('Check Valet+ PHP version...');
info('Run valet fix with the --reinstall option to trigger a full reinstall of the default PHP version.');

// If the reinstall flag was passed, uninstall PHP.
// If any error occurs return the error for debugging purposes.
if ($reinstall) {
$this->brew->ensureUninstalled(self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION]);
$this->brew->ensureInstalled(self::SUPPORTED_PHP_FORMULAE[self::PHP_V72_VERSION]);
}

// Check the current linked PHP version. If the current version is not the default version.
// Then relink the default version.
if ($this->linkedPhp() !== self::PHP_V72_VERSION) {
$this->unlinkPhp(self::PHP_V72_VERSION);
$this->linkPhp(self::PHP_V72_VERSION);
}

// Untap the deprecated brew tap.
if ($this->brew->hasTap(self::DEPRECATED_PHP_TAP)) {
Expand Down

0 comments on commit 3db9d71

Please sign in to comment.