Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We’ll explore valet, which is a development environment for macOS minimalists. It’s a lightweight Laravel development environment that uses approximately 7 MB of RAM.

Laravel Valet configures your Mac always to run Nginx in the background when your machine starts. You can use DnsMasq – is a Valet proxies for all requests on the *.test domain to point to sites installed on your local machine.

It’s an alternative of Sail or Homestead tool for local Laravel environments. You can even share your sites publicly using local tunnels.

Laravel valet GitHub

You can also access Laravel Valet on github: https://github.com/laravel/valet.

Prerequisites

Please make sure your machine satisfies the following requirements before proceeding with the valet installation:

  • macOS operating system
  • Homebrew installed: This is a package manager for macOS.
  • PHP installed in your system
  • Composer installed: This is a dependency manager for PHP.

Installation of Laravel Valet

Let us take you step-by-step through the process of setting up your development environment, installing Valet, and configuring it for Laravel.

Installation Of Homebrew

Please make sure that Homebrew is running and up to date using the update command. Open Terminal and run the following command to update Homebrew:

brew update

Install Composer

Let’s install composer(php package manager) using the below command:

brew install composer

Make sure the Composer global bin directory is in your system’s $PATH:

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

Install PHP

Next, you should use Homebrew to install PHP:

brew install php

Check PHP version:

php -v

Finally, You can install Laravel Valet as a global Composer package:

composer global require laravel/valet

Now, install all dependencies of valet by running the following command:

valet install

This command will configure and install Valet and DnsMasq

How To Change PHP Version

Valet allows you to switch PHP versions using the valet using the below command.

valet use [email protected]

Or by using .valetrc file, You need to create this file in the root of your project.

[email protected]

Laravel Project Setup

In case you don’t already have one, open your projects folder and start a new Laravel project:

laravel new my-laravel-project

Valet Park

Open the command line and navigate the directory where you store your Laravel projects, and run the following command:

valet park

The above command will automatically detect and serve any Laravel projects within this directory.

Accessing Your Laravel Project

Visit http://my-laravel-project.test in your web browser. Valet automatically creates a secure URL for your Laravel project.

Conclusion

We have successfully installed and configured Laravel Valet into your Mac system. You can develop, test, and deploy Laravel applications easily by using this tutorial. You can refer to the official Laravel Valet documentation: https://laravel.com/docs/8.x/valet.

Leave a Reply

Your email address will not be published. Required fields are marked *