How to Install Laravel in MacOS – An step by step guide

In this tutorial, we will walk you through the process of installing Laravel on a Windows operating system. By following these steps, you’ll not only install Laravel but also have a fully functional Laravel environment ready for your web development projects.Laravel, an elegant PHP framework, empowers developers to build feature-rich web applications with ease.

Step 1: Install Homebrew

  1. Launch the Terminal application on your macOS system.
  2. Install Homebrew by pasting the following command and following the on-screen instructions:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Step 2: Install PHP and Composer

Install PHP using Homebrew:

brew install php

Install Composer globally:

brew install composer

Step 3: Install Valet

Install Valet using Composer:

composer global require laravel/valet

Once the installation is complete, run the following command to set up Valet:

valet install

Step 4: Create a Laravel Project

  1. Navigate to the directory where you want to create your Laravel project using the Terminal.
  2. Run the following command to create a new Laravel project:
laravel new your-project-name

Replace your-project-name with your preferred project name.

Step 5: Configure Valet

Navigate to your project’s directory:

cd your-project-name

Run the following command to park your Laravel project with Valet:

valet park

Step 6: Access Your Laravel Project

Open a web browser and visit http://your-project-name.test. Valet automatically generates a secure URL for your project.

Step 7: Configure Your Database

If you don’t have MySQL installed, you can use Homebrew to install it:

brew install mysql

Step 8: Configure Environment Variables

  1. Rename the .env.example file in your project’s root directory to .env.
  2. Open the .env file and configure the database connection settings (DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD) to match your MySQL setup.

Step 9: Generate Application Key

Generate a unique application key by running the following command:

php artisan key:generate

Step 10: Test Your Installation

Visit http://your-project-name.test in your web browser. You should see the Laravel welcome page.

By following this comprehensive tutorial, you have successfully installed Laravel on your macOS system. With a fully operational development environment, you are well-equipped to embark on your web development journey using the powerful Laravel framework. Happy coding!

Leave a Reply

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

Post comment