Version Show
Laravel Valet
IntroductionLaravel Valet is a development environment for macOS minimalists. Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using DnsMasq, Valet proxies all requests on the In other words, Valet is a blazing fast Laravel development environment that uses roughly 7 MB of RAM. Valet isn't a complete replacement for Sail or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM. Out of the box, Valet support includes, but is not limited to:
However, you may extend Valet with your own custom drivers. Installation
To get started, you first need to ensure that Homebrew is up to date using the
Next, you should use Homebrew to install PHP:
After installing PHP, you are ready to install the Composer package manager. In addition, you should make sure the
Finally, you may execute Valet's
Once Valet is installed, try pinging any Valet will automatically start its required services each time your machine boots. PHP VersionsValet allows you to switch PHP versions using the
You may also create a
Once this file has been created, you may simply execute the
DatabaseIf your application needs a database, check out DBngin. DBngin provides a free, all-in-one database management tool that includes MySQL, PostgreSQL, and Redis. After DBngin has been
installed, you can connect to your database at Resetting Your InstallationIf you are having trouble getting your Valet installation to run properly, executing the Upgrading ValetYou may
update your Valet installation by executing the Serving SitesOnce Valet is installed, you're ready to start serving your Laravel applications. Valet provides two commands to help you serve your applications: The park CommandThe
That's all there is to it. Now, any application you create within your "parked" directory will automatically be served using the The link CommandThe
Once an application has been linked to Valet using the If you would like to serve the application at a different hostname, you may pass the hostname to the
Of course, you may also serve applications on subdomains using the
You may execute the
The
Securing Sites With TLSBy default, Valet serves sites over HTTP. However, if you would like to serve a site over encrypted TLS using HTTP/2, you may use the
To "unsecure" a site and revert back to serving its traffic over plain HTTP, use the
Serving A Default SiteSometimes, you may wish to configure Valet to serve a "default" site instead of a
Per-Site PHP VersionsBy default, Valet uses your global PHP installation to serve your sites. However, if you need to support multiple PHP versions across various sites, you may use the
If your site name does not
match the name of the directory that contains it, you may specify the site name using the
For convenience, you may use the
You may execute the
To revert a site back to Valet's globally installed PHP version, you may
invoke the
Sharing SitesValet even includes a command to share your local sites with the world, providing an easy way to test your site on mobile devices or share it with team members and clients. Sharing Sites Via NgrokTo share a site, navigate to the site's directory in your terminal and run Valet's
To stop sharing your site, you may press
Sharing Sites Via ExposeIf you have Expose installed, you can share your site by navigating to the site's directory in your terminal and running the
To stop sharing your site, you may press Sharing Sites On Your Local NetworkValet restricts incoming traffic to the internal If you wish to allow other devices on your local network to access the Valet sites
on your machine via your machine's IP address (eg: If you have not run Once you have updated your Nginx configuration, run the Site Specific Environment VariablesSome applications using other frameworks may depend on server environment variables but do not provide a way for those variables to be configured within your project. Valet allows you to configure site specific environment variables by adding a
Proxying ServicesSometimes you may wish to proxy a Valet domain to another service on your local machine. For example, you may occasionally need to run Valet while also running a separate site in Docker; however, Valet and Docker can't both bind to port 80 at the same time. To solve this, you may use
the
You may remove a proxy using the
You may use the
Custom Valet DriversYou can write your own Valet "driver" to serve PHP applications running on a framework or CMS that is not natively supported by Valet. When you install Valet, a All three methods receive the Once you have completed your custom Valet driver, place it in the Let's take a look at a sample implementation of each method your custom Valet driver should implement. The |
Command | Description |
---|---|
valet list
| Display a list of all Valet commands. |
valet forget
| Run this command from a "parked" directory to remove it from the parked directory list. |
valet log
| View a list of logs which are written by Valet's services. |
valet paths
| View all of your "parked" paths. |
valet restart
| Restart the Valet daemons. |
valet start
| Start the Valet daemons. |
valet stop
| Stop the Valet daemons. |
valet trust
| Add sudoers files for Brew and Valet to allow Valet commands to be run without prompting for your password. |
valet uninstall
| Uninstall Valet: shows instructions for manual uninstall. Pass the --force option to aggressively delete all of Valet's resources.
|
Valet Directories & Files
You may find the following directory and file information helpful while troubleshooting issues with your Valet environment:
~/.config/valet
Contains all of Valet's configuration. You may wish to maintain a backup of this directory.
~/.config/valet/dnsmasq.d/
This directory contains DNSMasq's configuration.
~/.config/valet/Drivers/
This directory contains Valet's drivers. Drivers determine how a particular framework / CMS is served.
~/.config/valet/Extensions/
This directory contains custom Valet extensions / commands.
~/.config/valet/Nginx/
This directory contains all of Valet's Nginx site configurations. These files are rebuilt when running the install
and secure
commands.
~/.config/valet/Sites/
This directory contains all of the symbolic links for your linked projects.
~/.config/valet/config.json
This file is Valet's master configuration file.
~/.config/valet/valet.sock
This file is the PHP-FPM socket used by Valet's Nginx installation. This will only exist if PHP is running properly.
~/.config/valet/Log/fpm-php.www.log
This file is the user log for PHP errors.
~/.config/valet/Log/nginx-error.log
This file is the user log for Nginx errors.
/usr/local/var/log/php-fpm.log
This file is the system log for PHP-FPM errors.
/usr/local/var/log/nginx
This directory contains the Nginx access and error logs.
/usr/local/etc/php/X.X/conf.d
This directory contains the *.ini
files for various PHP
configuration settings.
/usr/local/etc/php/X.X/php-fpm.d/valet-fpm.conf
This file is the PHP-FPM pool configuration file.
~/.composer/vendor/laravel/valet/cli/stubs/secure.valet.conf
This file is the default Nginx configuration used for building SSL certificates for your sites.
Disk Access
Since macOS 10.14, access to some files and directories is restricted by default. These restrictions include the Desktop, Documents, and Downloads directories. In addition, network volume and removable volume access is restricted. Therefore, Valet recommends your site folders are located outside of these protected locations.
However, if you wish to serve sites from within one of those locations, you will need to give Nginx "Full Disk Access". Otherwise, you may encounter server errors or other unpredictable behavior from Nginx, especially when serving static assets. Typically, macOS will automatically prompt you to grant
Nginx full access to these locations. Or, you may do so manually via System Preferences
> Security & Privacy
> Privacy
and selecting Full Disk Access
. Next, enable any nginx
entries in the main window pane.