- properly detects if the requested version is already installed, and skips re-installing/re-starting/re-configuring
- allows --force to re-configure anyway
- smarter treatment of 'php' when it's aliased to another specific installed version
Fixes#756
Previously if `php` was installed as just `php` (the default Homebrew alias), Valet would not detect *which* PHP version was actually installed, and therefore `valet use` might do incorrect or unnecessary installations/links/etc.
NOTE: This does NOT "convert" existing `php` alias to a numbered version. It merely accepts it as-is, but notes its version in an attempt to avoid extra installations.
*NOTE: Specifally tested with PHP 7.4 and 7.3. No promises about old 5.6, etc aliases.*
`valet uninstall` only displays information about how to manually uninstall and clean up after Valet.
This PR adds a `--force` parameter, which will forcefully remove Valet and the Homebrew services it installs, as well as clean up the config files and log files.
But for a few post-uninstall composer dependencies, cleanup is very thorough.
This brings idempotency to both `valet install` and `valet uninstall --force`
(There may still be edge cases where other Homebrew or composer packages might create interference with install/uninstall, but this makes things much easier to self-troubleshoot.)
If you've previously run `valet trust` to allow valet to run without specifying `sudo` repeatedly or entering your password with various valet commands, recent updates to MacOS may give you a `sudo: sorry, you are not allowed to preserve the environment` response when trying to run those `valet` commands.
The fix is in updating the sudoers entry that `valet trust` creates.
This PR tells valet how to update the sudoers entry so that this message doesn't continue.
YOU WILL NEED TO RE-RUN `valet trust` IF YOU HAD PREVIOUSLY RUN IT, after installing this update, in order for this code change to have any effect.
(Technical explanation: the sudoers protections have become stricter, so we have to be more explicit that we do indeed want environment variables to flow through to the sudo user's environment when using valet via sudoers entries.)
Last year's Homebrew's PHP packaging changes altered their version numbering strategy.
Now that their changes appear to have stabilized, Valet also needs some updates to match.
The `linkedPhp()` function was parsing the symlinked directory name for where the php binaries are stored, but that numbering strategy has morphed over time.
This PR changes the logic to accommodate the most common directory naming strategies I can find, including those of older installs.
I've included some examples of these names in code comments for future reference since finding a variety of them can be complicated.
* Revert "wip"
This reverts commit 15c961e41e.
* Revert "fix changes where brew php paths now include @ and semver-style versions in paths (#545)"
This reverts commit 7f61475feb.
Update supportedPhpVersions to include the new names used by homebrew now that the php packages have migrated to 'core'. php71 has become php@7.1 etc
The new names are put at the front of the list to optimise the loops that use these collections.
Anyone who installs or updates 'homebrew php' from will start using the new packages names which breaks parts of valet.
* Correct the return type annotation in a serves method
* Type-hint the driver in the abstract ValetDriver
* Correct the return type-hint in the sample ValetDriver
* Remove the return afrom the restartLinkedPhp method
* Remove the return annotation from the Caddy constructor
* Remove the return annotation from the Valet configuration constructor
* Removed the return from the prependPath method of the Configuration class
* Removed the return from the appendAsUser method of the Filesystem class
* Removed the return annotation from the Site constructor
* Corrected the parameter annotation of the link method in the Site class
* Order use statements by length in PhpFpm
* Remove the return annotation from the Valet constructor
* Allows for valet to run under PHP 5.5 as well.
Add checks for php55 to the mix.
* Allows for valet to run under PHP 5.5 as well.
Add checks for php55 to the mix.
* Update .travis.yml
* Update PhpFpm.php
* Add tests for php55