Post

Create a Local Dev Environment with Valet

What is Laravel Valet?

Laravel Valet is a development environment for macOS that makes it easy to create and manage local development environments for PHP applications, particularly those built using the Laravel framework. It is designed to be lightweight, fast, and easy to use.

Key features of Laravel Valet include:

  1. Nginx and Dnsmasq: Valet uses Nginx as the web server and Dnsmasq to manage local DNS resolution, allowing you to access your projects using a .test domain.
  2. Automatic Site Routing: Valet automatically maps the directory name of your project to a .test domain, so you can access your Laravel project in the browser by navigating to, for example, http://myproject.test.
  3. HTTPS Support: Valet provides automatic SSL certificate creation, enabling secure HTTPS connections for your local development sites.
  4. Database Support: Valet comes with support for MySQL and PostgreSQL out of the box, making it easy to set up and manage databases for your projects.
  5. Simple CLI Commands: Valet provides a set of simple command-line tools to manage your development environment, including commands for starting, stopping, and restarting the Valet service.
  6. Tinker Integration: Laravel Valet integrates with Laravel’s Tinker REPL, allowing you to interact with your application using a command-line interface.

To get started with Laravel Valet, you typically need to install it using Composer and follow the setup instructions provided in the official documentation. It’s a popular choice among Laravel developers for creating local development environments due to its simplicity and efficiency. Keep in mind that Laravel Valet is specific to macOS environments.

Serve a single site

After installing your php framework or cms, run the below command in your projects root directory, you can now access the site at the currentdirectoryname.test

1
valet link

As the docs say run this command in your sites directory to create test sites of all sub sites

1
valet park

Stop Valet

1
valet stop

display what links you have

1
valet links

Troubleshooting

502 bad getway. when trying to access local valet site. Running this command fixed it for me:

1
valet install
This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.