Laravel

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:

Related Post

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 php@8.1

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

php=php@8.1

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.

Recent Posts

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

2 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

2 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

3 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

3 months ago

Common Practices for Laravel Blade Template

in this Laravel tutorial, I will explore common practices for using the Laravel Blade template with examples. Blade is a… Read More

4 months ago

Laravel firstOrNew, firstOrCreate, firstOr, updateOrCreate With Example

in this article, we'll discuss some useful methods of Laravel eloquent model class. The methods are: firstOrNew(), firstOrCreate(), firstOr(), and… Read More

4 months ago

Categories