← Back to blog

Published on 02/12/2021 20:48 by Elian Van Cutsem

Using Laravel Valet for local PHP development

This week I’ve been developing PHP and Twig at my internship at vBridge, since we’re using a big pile of sourcecode, Docker doesn’t perform as well. To fix this Bramus told me about a tool called Valet. So I went on the search to configure and install Valet.

Installing Valet

Installing Valet is actually really easy. They have incredible documentation (as usual with Laravel).

You can simply install it by using composer global require laravel/valet if you’ve installed Homebrew, PHP and Composer, else you should install those first (but also that is very easy). Once that’s done, simply run valet install and Valet will install and start.

Now that valet is installed and started you’ll be able to ping any .test domain and it’ll answer from localhost or

Valet also starts when you boot your computer and will run as a background process with only 7mb of RAM!

Also, Valet is MacOS only

So installing is easy, so mapping a domain shouldn’t be hard right! just cd into the directory you want to run as a site and run valet link and the name of the directory will be used as domain. For insance:

cd laravelsite
valet link

Now when you open your browser and go to laravelsite.test. It will magically appear on the screen! awesome right!

You can also name a link by running valet link <name>. For instance:

cd laravelsite
valet link newsite

Now it’s available at newsite.test

It’s amazing!

Valet use

So, imagine that you’re developing a website on your local machine with the newest version of PHP, but the server you’ll be deploying to uses a much older PHP version. You don’t want to put in the work to install a new old version right? Valet got you covered!

Just run valet use php@version and valet will use that version. If you don’t have the version installed locally, it will install it for you.

But ofcourse, sphp is a valid choice too.

Valet Secure

Tired of the stupid browser notification that localhost isn’t secured? Me too. Valet also has a nifty solution. Run valet secure <name>x and it will install a certificate for you.

It’s insane how easy this all is!


Ofcourse if you’re a somewhat more demanding user. It can be interesting to use and create custom environment variables.

Valet has support for a file called valet-env.php and will use it to configure and use environment variables

For instance:


return [
 'newsite' => [
  'APP_ENV' => 'dev',

Now when you’ll open newsite.test in your browser, it’ll have the dev environment!

Read the post about environment variable from Bramus here

Read the full documentation here!

Written by Elian Van Cutsem

← Back to blog

Recent Blogposts

  • So, I'm leaving vBridge

    So, I'm leaving vBridge

    After spending a couple of years at vBridge Cloud, I'm leaving the company. I've worked at vBridge eversince I graduated. Now, It's time for a new adventure! I'm joining the DX-team at Astro full-time!

  • Becoming an Astro maintainer

    Becoming an Astro maintainer

    Since a week, I'm an Astro maintainer, in this post, I describe the process and my start in open source. I also give some insight in what I'm planning to work on.

  • 🍱 Brutal: A theme for Astro

    🍱 Brutal: A theme for Astro

    Brutal is a minimal neobrutalist theme for Astro. It's based on Neobrutalist Web Design, a movement that aims to create websites with a minimalistic and functional design. It has some integrations like Image Optimization, RSS, Sitemap, ready to get your SEO done right.

  • 🎤 Am I an international public speaker now?

    🎤 Am I an international public speaker now?

    A few weeks ago, I gave my first international keynote talk at JSWorld in Amsterdam. In this blogpost, I wanted to share some insights about the conference and my talk.

  • ✨ Building Blog tag index pages in Astro

    ✨ Building Blog tag index pages in Astro

    I wanted to add blog tag collection pages to my website. This way, people could filter on tags I used in my blog posts. Here is a guide on how I implemented it.

  • 🎉 I started from scratch (again)

    🎉 I started from scratch (again)

    I started rebuilding my personal website from scratch in Astro again, no dependencies, no frameworks, no nothing. This to decrease technical debt and make full use of the newer Astro features.