How to Setup Laravel Valet on Mac

Chukwuyenum Opone
3 min readMar 19, 2022
https://github.com/cretueusebiu/valet-windows

Installing Homebrew in Mac

This tutorial requires the Homebrew package manager installed on your development machine. You can execute the following command from your terminal window:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

If you have already installed the Homebrew package manager, then skip this step and jump on to the other step.

This is a step-by-step tutorial on Laravel Valet.

In this Laravel 8 tutorial, we are going to learn how to set up or configure a Laravel development environment on the Mac and how to run laravel web applications through the Laravel Valet mechanism.

Configure PHP in Mac

Laravel is a PHP framework, so we need to install the latest PHP version using Homebrew.

You need to fire the following command from a command prompt:

brew install php

MySQL Installation

Of course, to store the data, we need a database, and what else could be better than MySQL. We can download it through the Homebrew package manager:

brew install mysql

brew services start mysql

Check here for the full installation guide with sequel pro(Setting up MySQL on mac with sequel pro and homebrew)

Install Composer on MacOS

Composer is a package manager same as NPM. It helps you download the packages and libraries to amplify your application development workflow.

To install the composer, you need to run the following command.

sudo php -r “copy(‘https://getcomposer.org/installer','composer-setup.php');"

The hash file code for the composer verifies the installer.

php -r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ‘795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”

Next, we execute the composer-setup.php file;

it helps in installing the Composer package in the existing directory.

php composer-setup.php

Or

Ultimately, we have to configure the composer globally in our development system. So, it would be best if you run the given below command, It will shift the composer.phar file to local user’s bin directory.

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

Verify the impetus of the Composer package manager installation by running.

composer

If the composer displays composer info without errors, go ahead to download the Laravel installer using Composer :

download Laravel Valet via Composer

Laravel Valet can be installed with just one command:

composer global require laravel/valet

Once downloaded, the installation packages come along with it:

Run the following command to set the following folder with the path:

Go to root in the terminal and run

touch .zshrc

nano .zshrc

export PATH=$HOME/.composer/vendor/bin:$PATH

source .zshrc

echo $PATH

Now we need to install the Laravel Valet with given below command:

valet install

Create Laravel Application with Valet

In this final step, we learn how to run a laravel project using laravel valet’s link and park commands.

mkdir laravel

Get inside the project root:

cd laravel

Run the laravel valet park command:

valet park

The above command registers the existing laravel project directory as a path for Valet.

Create a new Laravel web application inside the same folder:

laravel new shop

With the following URL, you can check out the laravel application that we installed via Valet.

http://shop.test/

--

--

Chukwuyenum Opone

A software and game programmer with over 5 years in tech and gaming, driven by innovation and a passion for AI, and a way with words.