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:
- 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.
- 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.
- HTTPS Support: Valet provides automatic SSL certificate creation, enabling secure HTTPS connections for your local development sites.
- 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.
- 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.
- 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
List Valet links
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