Valet Plus
Deprecated — this content is not maintained and possibly out of date.
I switched from Valet Plus to Valet in 2021 because my personal sites don’t have databases.
Valet+ is the “blazing fast macOS PHP development environment”.
Documentation
Valet+ extends the original Laravel Valet features. Refer to both for the full documentation.
Install
Follow the install docs.
Update
composer global require weprovide/valet-plus
valet install
Commands
Managing Valet+
valet start |
Start the Valet daemon. |
valet restart |
Restart the Valet daemon. |
valet stop |
Stop the Valet daemon. |
valet uninstall |
Uninstall the Valet daemon entirely. |
Run valet stop
before enabling other environments which use the same ports (MAMP/Docker/etc).
Managing sites
The park
command
- Navigate to folder:
cd ~/path/to/sites
- Run
valet park
- Each sub-folder will be available as:
http://foldername.test
valet park |
Link all sub-folders as: http://foldername.test |
valet paths |
View all of your “parked” paths. |
valet forget |
Run this command from a “parked” directory to remove it from the parked directory list. |
The link
command
- Navigate to folder:
cd ~/path/to/site/root
- Run
valet link {linkName}
- The site will be available as:
http://{linkName}.test
valet link {linkName} |
Add a linked directory. |
valet links |
View all of your linked paths. |
valet unlink {linkName} |
Remove a linked directory. |
Managing databases
- Username:
root
- Password:
root
valet db ls |
List databases |
valet db create {name} |
Create database |
valet db drop {name} |
Drop database |
valet db export {databaseName} |
Export database as {databaseName}-{date}.sql.gz |
valet db export {fileName} {databaseName} |
Export database as {fileName}.sql.gz |
valet db import {fileName}.sql {databaseName} |
Import database from file (.sql or .sql.gz) |
valet db open {name} |
Open database in Sequel Pro |
Securing sites
Command | Outcome |
---|---|
valet secure hobbiton |
https://hobbiton.test |
valet unsecure hobbiton |
http://hobbiton.test |
Sharing sites
- Navigate to the site’s path in terminal.
- Run
valet share
. - Copy the site URL.
- Type
Control + C
to stop sharing.
Switch PHP version
valet use 7.1
or valet use 7.2
You might need to run valet restart
afterwards.
Troubleshooting
PHP goes insane
🔥🔥🔥 Hot drama alert — I don’t like Homebrew and this is why.
When Homebrew removed “taps” for PHP and made them part of homebrew/core
it broke Valet+ for a lot of people. About 6 months later, Homebrew made the latest PHP the default, which broke it again. So Valet+ decided maintain their own PHP taps, but that also broke my existing Valet+ install.
PHP extensions already loaded
Sometimes removing and reinstalling PHP via Homebrew causes php.ini
to load the same PHP extension multiple times, which breaks with an error like:
PHP Warning: Module 'apcu' already loaded in Unknown on line 0
Luckily that’s easy to fix:
# Identify your PHP version
php -v
which php
# Should be like: /usr/local/bin/php
# Which is symlinked to: /usr/local/Cellar/[email protected]/7.2.20/bin/php
# Which uses this INI file: /usr/local/opt/valet-php/7.2/php.ini
# Note: Valet symlinks this PHP version into your $PATH.
# Your shell profile can force a different PHP version. Double-check that.
# Edit the php.ini file
nano /usr/local/opt/valet-php/7.2/php.ini
At the top of the file, find and remove duplicate lines. Example:
extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20170718"
Save and run valet install
again.
Reference
MySQL goes insane
🔥🔥🔥 Hot drama alert — I don’t like Homebrew and this is why.
When installing Valet+ you see this error in the console log:
Setting password for root user failed.
First try this:
brew link --force [email protected]
valet install
valet db ls
Hopefully that works.
Totally reinstall MySQL via Homebrew
If Homebrew somehow installs/updates to MySQL 8 — that breaks Valet+, which requires MySQL 5.7. You’ll waste hours trying to reinstall Valet+ or MySQL but nothing will work. You have to scorch any trace of MySQL ever existing on your computer, restart, then destroy and reinstall Valet+ so it can install the MySQL version it requires. Follow this guide:
Related issues
- GitHub — Issue #56 warnings and errors in the output of “valet db ls”
- GitHub — Issue #238 ping magento2.test after install, reboot returns 100% packet lost
- GitHub — Issue #246 setting password for root user failed
- GitHub — Issue #270 setting password for root user failed
MySQL access denied
When you get this error, don’t touch MySQL or Homebrew. It’s fixable by restarting and toggling HTTPS on/off for the site in Valet+. No idea why this works.
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
- Try
valet restart
. - Try
valet unsecure {name}
thenvalet secure {name}
.