◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Local → Laravel Valet
Build a local development environment with Valet and WordPress
Just like WordPress has specific tools like VVV for local WordPress development, the wider PHP community has similar tools. Today we’re going to look at Valet, a tool for hosting Laravel projects locally.
While Valet was released by the Laravel team, it is designed to support WordPress out of the box, along with other CMSs like Craft, Drupal, and Statamic.
Let’s dig into how to get a WordPress site running on Valet.
Pros and cons of Valet
Pros
It has a simple setup process, allowing developers to get started quickly without complex configurations.
It is lightweight and fast, using minimal system resources for a smooth and efficient local development experience.
It integrates smoothly with Laravel, offering automatic configuration and optimized performance.
It supports a wide range of PHP frameworks and CMS platforms, including WordPress, Drupal, Craft, and Statamic, providing flexibility for different projects.
It automatically manages SSL certificates, simplifying the process of setting up secure local development environments.
Cons
It’s only available on macOS, leaving Linux and Windows users without native support, although forks and alternatives like WSL may work.
It’s best suited for simple projects and may not support more complex configurations or advanced setups.
It relies on Homebrew for installation and management, which might be inconvenient for users unfamiliar with this package manager.
It does not have a graphical user interface, meaning developers must manage everything via the command line.
How to set up WordPress locally with Valet
Valet pre-install preparation
The setup process is a bit different from other local WordPress development tools like XAMPP and MAMP as we need some other terminal-based tools installed before we can get Valet running.
First, we’ll need to install Homebrew, a package manager for macOS Terminals. We’ll need this to install the packages that will make up Valet. If this feels daunting to start, don’t worry. There are only a handful of basic commands we need to run.
To install Homebrew, use the command below:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"You’ll be greeted by some prompts to set up Homebrew. They’re all very clear so just follow them and it will be set up for you.
Before we go forward we need to make sure that we have the most recent package definitions for Homebrew. To do this we need to update it with the commands below.
brew doctorto makes sure that nothing needs fixing in your current installation.brew updateto ensure you’re running the latest version.
If your system doesn’t find Homebrew in your $PATH then you can add it using export PATH="/usr/local/bin:$PATH"
If you have other errors, check the Homebrew troubleshooting guide.
Next, let’s get the latest version of PHP installed:
brew install phpHow long this takes depends in part on your internet connection since Homebrew has to download PHP. Once it’s downloaded Homebrew will set up PHP on your system.
Finally, we need to make sure that Composer is installed on our system. Use the following commands to download, run, and delete the installer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'.PHP_EOL; } else { echo 'Installer corrupt'.PHP_EOL; unlink('composer-setup.php'); exit(1); }"
php composer-setup.php
php -r "unlink('composer-setup.php');"This will install Composer as composer.phar, but if you want to call it as just composer, from any directory, use the following command:
sudo mv composer.phar /usr/local/bin/composerInstalling Valet on your system
Now that we have everything set up, it’s time to install Valet via Composer with the command below.
composer global require laravel/valetIf you get errors it’s possible that you need to download some more dependencies. If so run the command above with –with-all-dependencies to make sure they get downloaded.
Now that we have Valet downloaded we need to set it up. Run the following command in Terminal. You should be prompted for your password before this command runs.
valet installNow we have Valet installed, so we can move on to getting a WordPress site setup.
Installing WordPress inside Valet
There are two basic commands you’ll need to know to use Valet effectively.
- park to add a directory to Valet. If you created a folder called ~/valet-sites you would use the park command to add that whole folder as a spot that sites could run out of.
- link to add a single site folder to Valet instead of a whole directory where you’d run different sites.
Now we need to download WordPress so that we can use it to create a Valet-based site to work on. Unzip the download and rename the folder to something like valet-project.
Next, in the terminal, move into the new directory with cd path/to/valet-project and then run valet link to link that directory into Valet so you can use it to host WordPress.
Now you should be able to visit valet-project.test in your browser and see the WordPress install screen.
Before you move through the WordPress setup, though, we need to install a database layer because Valet doesn’t come with that. We can install MySQL via Homebrew with the following command.
brew install mysqlOnce MySQL has been installed we need to start it.
mysql.server startTo stop MySQL you’d use mysql.server stop.
Now you can connect to the Valet database with your favourite local database tool and create a new database.
Then simply finish the WordPress install and get working on your new site.
You can also use Valet for WordPress multisite projects, same setup process and all, but there are considerations you need to make depending on whether you choose to use subdomains or subdirectories.
If you opt for subdomains, you’ll need to use the link command to source each one from the original directory, e.g.:
valet link site1.valet-project.siteThis should also work for domain mapping, and Valet will handle all DNS wildcards automatically.
Unfortunately, Valet isn’t compatible with the subdirectory setup out of the box, but you can install the WordPress Multisite Subdirectory Valet Driver to add support.
Ready to launch?
Valet is a great way to set up WordPress locally. When you’re ready for cloud hosting, look no further than the hosting provider that has been delivering fast, secure WordPress sites for almost three decades.
Liquid Web offers the widest range of hosting options specifically designed for WordPress sites — from a simple VPS, to WordPress cloud hosting, to dedicated WordPress servers for enterprise organizations. You choose your favorite OS and the level of management support you need. Get in touch today.
Additional resources
How to install WordPress on localhost →
A beginner’s guide to WordPress local and how to get started
How to Install WordPress on Linux →
8 steps to get you started on AlmaLinux
How to ask WordPress plugin developers for help →
(… and how NOT to.)
Curtis McHale is a husband, father, developer and business coach. He specializes in helping people build a business that lets them spend time with their family instead of working all the time.