How to Install Laravel Valet on Mac

Alfredo Barron
Dec 18, 2019 · 2 min read

Configure your development environment on Mac in minutes

Step 1. Install Homebrew

In first step, we require to get Homebrew using bellow command, So open your terminal or command prompt and run bellow command

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Step 2. Install PHP

Install PHP 7.4 using Homebrew via

brew install php

Step 3. Install MySQL

Install MySQL 5.7 using Homebrew via

brew install mysql@5.7

Once MySQL has been installed, you may start it using the bellow command

brew services start mysql@5.7

Step 4. Install Composer

Install Composer run bellow command

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

After the command, you will have composer.phar file in the current directory and the composer command is available as:

php composer.phar [composer commnad]

In order to make composer available globally, you have to move the recently downloaded composer.phar to local user’s bin folder using bellow command:

mv composer.phar /usr/local/bin/composer

Now, you can access the composer from the terminal simply using the composer command. Thats it.

Step 5. Install Valet

Install Valet run bellow command:

composer global require laravel/valet

If you have a problem with the “Changed current directory to”. You need to add this folder to your unix path. You can do this by running the following:

PATH=$PATH:~/.composer/vendor/bin

Run the bellow command. This will configure and install Valet and DnsMasq, and register Valet’s daemon to launch when your system starts.

valet install

Step 6. Serving Sites

Once Valet is installed, you’re ready to start serving sites. Valet provides two commands to help you serve your Laravel sites: park and link.

  • Create a new directory on your Mac by running something like mkdir ~/Sites. Next, cd ~/Sites and run valet park. This command will register your current working directory as a path that Valet should search for sites.
  • Next, create a new Laravel site within this directory: laravel new blog.
  • Open http://blog.test in your browser.

Thanks for reading!! If you like this… Give me your clapping and follow me on Instagram or Twitter.

References

modulr

Tutorials for Developers Laravel/AWS/Linux

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store