Serving sites
Once Valet Linux+ is installed, you're ready to serve sites. Valet offers two ways to do it: parking a directory and linking a single project.
The park command
valet park registers the current working directory (or a given path) as a projects root. Every directory inside it is served as http://<directory-name>.test.
mkdir ~/sites
cd ~/sites && valet park
That's all there is to it. Any project you create inside the parked directory is served automatically.
Example
mkdir ~/sites/example
cd ~/sites/example
echo "<?php echo 'Valet Linux+ at your service';" > index.php
Open http://example.test — you should see Valet Linux+ at your service.
Related commands:
valet park [path] # Register the current (or given) directory
valet paths # List all parked paths
valet forget [path] # Remove the current (or given) directory from the parked paths
The link command / domain aliases
valet link serves a single directory, and can also be used to create aliases.
Display all registered links:
valet links
Link the current directory (uses the directory name when no name is given):
valet link <name>
For example:
valet link yourproject2
serves the current directory at yourproject2.test.
Remove a link:
valet unlink <name>
Opening a site
valet open [name]
Opens the site of the current (or given) directory in your browser.
Which driver serves my site?
valet which
Shows which driver Valet uses to serve the current directory.
Securing sites with TLS
By default, Valet serves sites over plain HTTP. To serve a site over encrypted TLS using HTTP/2, use the secure command. For example, if your site is served at example.test:
valet secure example
Without arguments, the current directory's site is secured. Certificates are signed by a local certificate authority that Valet adds to your system and browsers' trust stores.
To "unsecure" a site and revert to plain HTTP:
valet unsecure example
Check whether a site is secured:
valet secured example
Changing the domain
Sites are served on the .test TLD by default. To view or change it:
valet domain # Show the current domain
valet domain local # Serve sites on *.local
Secured sites are re-secured automatically for the new domain.
Changing the ports
valet port # Show the current HTTP and HTTPS ports
valet port 8080 # Change the HTTP port
valet port 8443 --https # Change the HTTPS port
Proxy
Proxies let you serve any local service (Node, Docker, etc.) on a Valet domain with a single command:
valet proxy <domain> <host> [--secure]
Example:
valet proxy app http://localhost:3000 --secure
serves http://localhost:3000 at https://app.test. The .test suffix is added automatically when omitted, and the host must be a full http:// or https:// URL.
List proxies
valet proxies
Remove a proxy
valet unproxy <domain>
Site environment variables
Create a .valet-env.php file in the project root returning an array of variables. Keys under * apply to every site served from that directory; keys under a site name apply only to that site:
<?php
return [
'*' => [
'APP_ENV' => 'local',
],
'example' => [
'APP_DEBUG' => 'true',
],
];
The variables are exposed through $_SERVER, $_ENV and getenv().