Valet Linux+

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.

bash
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

bash
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:

bash
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

valet link serves a single directory, and can also be used to create aliases.

Display all registered links:

bash
valet links

Link the current directory (uses the directory name when no name is given):

bash
valet link <name>

For example:

bash
valet link yourproject2

serves the current directory at yourproject2.test.

Remove a link:

bash
valet unlink <name>

Opening a site

bash
valet open [name]

Opens the site of the current (or given) directory in your browser.

Which driver serves my site?

bash
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:

bash
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:

bash
valet unsecure example

Check whether a site is secured:

bash
valet secured example

Changing the domain

Sites are served on the .test TLD by default. To view or change it:

bash
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

bash
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:

bash
valet proxy <domain> <host> [--secure]

Example:

bash
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

bash
valet proxies

Remove a proxy

bash
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
<?php

return [
    '*' => [
        'APP_ENV' => 'local',
    ],
    'example' => [
        'APP_DEBUG' => 'true',
    ],
];

The variables are exposed through $_SERVER, $_ENV and getenv().