Laravel 11 for Beginners: Installing on MacOS and Windows

Arlind Musliu Portrait
Arlind Musliu

January 2, 2024 · 8 min read · 5,272 views

Install Laravel for MacOS Windows

2024 UPDATE - LARAVEL 11

We're excited to announce that we have updated all of our blog post examples to reflect the new Laravel 11 version! Our previous examples were based on Laravel 10, but with the release of Laravel 11, we wanted to ensure that our readers have access to the most up-to-date information and examples.

Install Laravel on MacOS / Windows

Building a modern application with Laravel requires setting up your development environment with various tools. For our daily work, we use the Laravel Herd Pro package, which has improved our performance and greatly reduced the number of bugs we encounter. We've made things simple by explaining how to install Laravel with Herd. But if you want to try something different, you can find instructions for Laravel Valet on MacOS and Laragon on Windows at the end of this article.

For MacOS users, Laravel Herd, Valet and Homebrew are popular solutions that simplify the installation, while Windows users can decide between Laravel Herd and Laragon for a hassle-free setup. We also include a step-by-step guide to installing PHP, Composer, Node.js, NPM, and setting up a database using SQLite or MySQL.

Laravel Herd Benefits

Laravel Installation For MacOS

Install Laravel for MacOS with Herd

Herd already has Composer and Node.js, so you can instantly use them from the terminal.

Step 1: Download and Install Laravel Herd

Download Laravel Herd from the official website and follow the installation instructions.

Step 2: Start Nginx

Launch Herd and it will show as a small H icon on the top-right of your screen. Right-click on it and see if Nginx is running with a green circle next to it. If not, click Start All.

Step 3: Project URLs Setup

Herd uses the concept of parked paths and linked directories for serving sites. Create a new folder Sites on your main directory. Open Herd Settings and on the Herd Paths add the newly created Site folder. After installation, your Laravel projects are automatically found at project-name.test.


Laravel Installation For Windows

Install Laravel for Windows with Herd

Herd already has Composer and Node.js, so you can instantly use them from the terminal.

Step 1: Download and Install Laravel Herd

Download Laravel Herd from the official website and follow the installation instructions.

Step 2: Start Nginx

Launch Herd and it will show as a small H icon on the bottom-right of your screen. Right-click on it and see if Nginx is running with a green circle next to it. If not, click Start All.

Step 3: Project URLs Setup

Herd uses the concept of parked paths and linked directories for serving sites. Create a new folder Sites on your Desktop. Open Herd Settings and on the Herd Paths add the newly created Sites folder. After installation, your Laravel projects are automatically found at project-name.test.

Laravel best PHP framework

Starting your first Laravel app

Open your terminal and navigate to your Site directory before installing Laravel.

Step 1: Laravel Install

Once you have PHP, Composer, Node.js, and NPM installed (through Laravel Herd or individually), you can install Laravel using Composer:

composer create-project laravel/laravel blog

This command will create a new Laravel project in a directory called blog.

Step 2: Setting Up the Database

We will show you how to set up SQLite and MySQL. It's up to you to decide which one to use. Just a heads-up, SQLite is the go-to database by default for Laravel 11. That's why we will keep it simple with SQLite for now, but at the end of the article, you can also learn how to install MySQL if you want.

SQLite - Laravel Database for MacOS and Windows

With the new Laravel 11 installation, the migration process occurs automatically during the installation, so the command php artisan migrate is not needed for now.

Keep in mind: If you clone an existing Laravel project, the SQLite file may be missing. You have to run the command touch database/database.sqlite and it will make the database.sqlite file in the database folder of the project you cloned locally.

Step 3: Serve Your Application

If you're using Laravel Herd or Valet, you can simply visit http://blog.test in your browser. The same applies even if you're a Windows user using Laravel Herd or Laragon.

Laravel Herd has the Sites tab where you can see the links and settings for each project you create. You can also switch from HTTP to HTTPS if needed. You can choose a different PHP version for each project as required and Herd will do it automatically for you.

Laravel Concepts Features Illustration

Laravel 11 for Beginners Series

Your application is ready and you can start playing around with it. We recommend that you continue learning more about Laravel by following our detailed guide series Laravel 11 for Beginners: A Step-by-Step Guide to Learn the Concepts.

The rest of the article will show you how to install Laravel through Valet for MacOS and Laragon for Windows users. Feel free to skip it if you already installed Laravel Herd as we explained above and continue with the Laravel 11 for Beginners: The MVC pattern lesson.

laravel pipelines

Install Laravel without Herd

Install Laravel for MacOS with Laravel Valet

Step 1: Install Homebrew

Open the Terminal and run the following command to install Homebrew:

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

Step 2: Install PHP

Use Homebrew command to install PHP:

brew install php

Step 3: Install Composer

Composer is a PHP dependency manager. Install it with Homebrew using

brew install composer

Step 4: Install Node.js and NPM

Node.js comes with NPM, and you can install both using Homebrew:

brew install node

Step 5: Install Laravel Valet

Install Valet with Composer and you will be able to access your site with blog.test. First run:

composer global require laravel/valet

Then run the following:

valet install

With Valet, you use the park command in a directory to serve all projects as individual sites. We usually save our projects in a Sites folder on our main directory, feel free to do the same. Navigate to your projects directory, for example cd Sites , then run:

valet park

Now, any Laravel project within this directory can be accessed via the project-name.test URL. For example, if your Laravel blog directory is named blog, you can access it at blog.test.

Install Laravel for Windows with Laragon

Laragon is a great alternative to WAMPP & XAMPP if you're familiar with those technologies. Laragon includes Composer, PHP, and many other development tools such as MySQL, Apache, Node.js, and more. It is a complete package for local development environment setup.

Step 1: Download Laragon

Make sure to download the latest version from the official Laragon site.

Step 2: Install Laragon

Just download the latest version and follow the on-screen instructions. Nothing too complicated.

Step 3: Start Laragon Services

Open Laragon and start the services you need. Choose Apache or Nginx as your web server to handle HTTP requests for your Laravel application. If you chose MySQL over SQLite, then you also need to start the MySQL service in Laragon.

Step 4: Check your new Laravel App!

Laragon uses a pretty URL where any Laravel project within the directory can be accessed via the project-name.test URL. For example, if your Laravel blog directory is named blog, you can access it at blog.test.

Laravel Migrations Data

Using MySQL for Laravel

Herd includes MySQL with the Pro package (which we highly recommend if you want to simplify things even more).

Install MySQL for Laravel

Install MySQL for MacOS

If you don't want to pay Herd Pro, we suggest installing MySQL with DBngin on your MacOS system, instead of manually installing it via Homebrew (if you prefer streetfighting). We also recommend installing TablePlus for managing your database data.

Install MySQL for Windows

Laragon already has MySQL installed for you so you simply have to make sure that it's running.

Update .env file - MacOS and Windows

Update your Laravel .env file to use the MySQL blog database created in DBngin (MacOS) or Herd (Windows).

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog
DB_USERNAME=root
DB_PASSWORD=

Now, simply run the migration script and you have your database ready:

php artisan migrate

legacy php migrate laravel

Serve Your Laravel Application Manually

If you're not using the services we mentioned above (Laravel Herd, Valet or Laragon), you can use the built-in PHP command to serve your Laravel application locally:

php artisan serve

This will start a development server at http://localhost:8000.

Conclusion

With these steps, you've set up your development environment on MacOS and Windows using Laravel Herd. You might have also chosen to use Homebrew for MacOS or Laragon for Windows. Now you have PHP, Composer, Node.js, NPM, and a database ready to go for your Laravel application project. Laravel's simplicity and elegance, combined with these tools, make for a powerful development experience, whether you're a beginner or an experienced developer.

Upcoming Articles in the Series

  1. Laravel for Beginners: The MVC pattern

  2. Laravel for Beginners: Model Relationships

  3. Laravel for Beginners: Laravel Migrations

This article is part of our series Laravel 11 for Beginners: A Step-by-Step Guide to Learn the Concepts.


Bring Your Ideas to Life 🚀

If you need help with a Laravel project let's get in touch.

Lucky Media is proud to be recognized as a Top Laravel Development Agency

Arlind Musliu Portrait
Arlind Musliu

Cofounder and CFO of Lucky Media

Technologies:

Laravel
Heading Pattern

Related Posts

Stay up to date

Be updated with all news, products and tips we share!