This week we will see a more interesting topic of “Laravel Valet”. It is a local development environment for Mac developers. There is no need of installing Vagrant, Apache, Nginx and no changes need to be done in /etc/hosts file. The most special feature of using Valet is that you can even share your sites publicly so that it can be viewed from anywhere in the world. Let’s see the step by step installation and the configurations that need to be done.
Installing Valet is very easy, it requires Mac operating system, composer and latest version of Homebrew.
- Install or update Homebrew to the latest version using brew update.
- Then install PHP 7 by,
brew install homebrew/php/php70
- Install Valet with Composer using.
composer global require laravel/valet
- Make sure the ~/.composer/vendor/bin directory is in your system’s “PATH”, you can check this by running:
If you can’t see it there, then you need to add this to your ~/.bash_profile:
- Finally, run the following command,
Serving Valet Site
- After Valet is installed, create a new folder to hold all your sites at “~/Projects”. cd into this directory:
- Next run the Valet park command:
This command will register your current working directory as a path that Valet should search for sites.
- Next, create a new Laravel site within the parked directory:
laravel new TestValet
Once it finishes installing visit TestValet.dev in the browser.
If you want to remove the parked directory from the parked directory list by using the command:
valet forget ~/Projects
Using Valet, you can share your local sites with the world.
To share your site, navigate to the site’s directory in your terminal and run the following command:
A publicly accessible URL will be inserted into your clipboard and is ready to paste directly into your browser. That’s it.
To stop sharing your site, hit Control + C to cancel the process.
Sites outside of your parked directory
You can link the projects in other places on your file system by using “link” command.
valet link TestBlog
Now you can hit TestBlog.dev in the browser and this site will load.
If you ever want to see a list of linked sites Valet offers the following command:
Then if you ever want to remove one:
valet unlink TestBlog
Securing a Valet site
Valet uses plain HTTP by default and with the release of 1.1.9 you can now easily serve sites over HTTPS by running:
valet secure TestBlog
Then to revert back to HTTP:
valet unsecure TestBlog
This is all managed by Caddy Server.
You can start, restart and stop the Valet daemon by
You can uninstall the Valet daemon entirely by
Valet provides a blazing fast local development environment with minimal resource consumption, so it’s great for developers who only require PHP / MySQL and do not need a fully virtualized development environment.
Hope this blog has helped you in installing and using the Valet. We will come back with more interesting and useful blog next time keep watching for updates.