Valet Plus

Blazing fast macOS PHP development environment

I first heard about Valet Plus while ago and have to admit that did not paid too much attention.

When you work in an agency every minute count and if your local environment does not work and you have to spend time fixing it you are dead.

If you come from an environment like Vagrant or Docker it is easier because everything is installed in a box or a container so you are free to play installing things in your laptop and if they don't work and you need to carry on working you can do vagrant up and continue the experiment in another time. Unfortunately that was not my case because, yes I use Vagrant for some of my projects but for the majority of them I use my local dev environment, in other words, Apache, MySql, Redis, etc. Everything Installed directly in MacOS.

This can cause some problems and when I first tried to install it I did not succeed so I ended going back to MacOS.

Recently I decided to give another chance. The following instructions summarise what I did to finally get it working.

First I uninstalled/deleted all the apps files related:

brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug php56-yaml
brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug php70-yaml
brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug php71-yaml
brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug php72-yaml
brew uninstall --force httpd
brew uninstall --force blackfire-php71
brew uninstall --force php
brew uninstall --force php@5.6
brew uninstall --force php@7.0
brew uninstall --force php@7.1
brew uninstall --force php@7.2
brew uninstall --force php@7.3
brew unlink valet-php@5.6 && brew uninstall valet-php@5.6
brew unlink valet-php@7.0 && brew uninstall valet-php@7.0
brew unlink valet-php@7.1 && brew uninstall valet-php@7.1
brew unlink valet-php@7.2 && brew uninstall valet-php@7.2
brew unlink php71 && brew uninstall php71 && brew uninstall --ignore-dependencies php71
rm -rf /usr/local/opt/valet-php@*
rm -rf /usr/local/opt/php*
rm -rf /usr/local/etc/valet-php/*
brew upgrade
brew update
brew cleanup
brew doctor

Make sure to fix any issue/warning highlighted by brew doctor.

Then follow the instructions to install Valet Plus and make sure it installs with no errors.

First Issue

When I tried to browse a site I got an error saying something like:

value of `$valetConfig['paths']` in `/Users/rdiaz/.composer/vendor/weprovide/valet-plus/server.php:55` was not an array…

After debugging I discovered that Valet tries to get config.json from $home/.valet/config.json but for some reason Valet created and filled the .valet/ directory inside /var/root/

I did not installed Valet using sudo and my $home directory was writable… so I don’t know why it does this.

The Fix

I fixed the issue, creating a symlink from var/root/.valet to $home/.valet/

Second Issue

When running valet fix I got:

No releases available for package “pecl.php.net/apcu_bc”
install failed

In my case there was a problem with openssl.

pecl tries to connect to pecl.php.net/apcu_bc but it seems like the http is not longer available. Then it tries to connect using https but for that, it needs openssl.

The Fix

I fixed the issue by reinstalling openssl:

brew reinstall openssl

Although is already mentioned in Valet installation instructions, I think it is worth to mention it again. You need to make sure nothing is listening to port 80.

For that you can use

sudo lsof -n -i -P | grep -i ":80 (LISTEN)"
$ sudo lsof -n -i -P | grep -i ":80 (LISTEN)"

nginx     34924           root    9u  IPv4 0xba753e697516dde7      0t0  TCP *:80 (LISTEN)
nginx     34933           john    9u  IPv4 0xba753e697516dde7      0t0  TCP *:80 (LISTEN)
nginx     34934           john    9u  IPv4 0xba753e697516dde7      0t0  TCP *:80 (LISTEN)
nginx     34935           john    9u  IPv4 0xba753e697516dde7      0t0  TCP *:80 (LISTEN)
nginx     34936           john    9u  IPv4 0xba753e697516dde7      0t0  TCP *:80 (LISTEN)

and if that shows something, just kill the processes as usual or use top / htop to kill the processes.

Third Issue

When running valet fix I got:

Error: Calling needs :cxx11 is disabled! There is no replacement.

After debugging and search on Internet about it I discovered that this was an actual issue in the php repository used by Valet.

The Fix

This one is quite easy. Just go to the homebre-php directory:

cd /usr/local/Homebrew/Library/Taps/henkrehorst/homebrew-php/Formula

And get the latest changes in master branch:

git fetch origin
git rebase origin/master

Comments

Next Post Previous Post