How to install Laravel on Windows and Mac

Updated: January 14, 2024 By: Guest Contributor Post a comment

Introduction

In this tutorial, we will look at how to install Laravel, a popular PHP framework used for web application development, on both Windows and Mac operating systems. We’ll walk through the process step-by-step, ensuring even beginners can follow along.

Before we start, make sure you have the following installed on your system:

  • PHP (version 7.3 or greater is recommended)
  • Composer — a dependency manager for PHP
  • A code editor of your choice (Visual Studio Code, Sublime, etc.)

Installation Step-by-Step

1. Install PHP

Windows:

- Download the latest PHP version from https://windows.php.net/download/
- Extract the downloaded ZIP file to a directory, for example, C:\php
- Add the directory to the Windows PATH environment variable

Mac (using Homebrew):

$ brew install php

2. Install Composer

Windows:

- Download the Composer installer from https://getcomposer.org/download/
- Run the installer and follow the prompts to complete the installation

Mac:

$ brew install composer

3. Installing Laravel

With PHP and Composer ready, you can now install Laravel using Composer:

$ composer global require laravel/installer

This command will install Laravel Installer as a global tool, which means you can create new Laravel projects from anywhere on your machine.

4. Creating a New Laravel Project

$ laravel new blog

This command creates a new Laravel project with the name ‘blog’ in a directory of the same name.

5. Serving Your Application

Once the project is created, you can navigate to your project’s directory and use the following command to start the Laravel development server:

$ cd blog
$ php artisan serve

This starts a local development server at http://localhost:8000 where you can see your application live.

Additional Tools and Configuration

In developing with Laravel, you might find the need for a database or additional extensions such as:

  • XAMPP/WAMP/MAMP for a full PHP development environment which includes a database server
  • Extensions like PDO and Mbstring which can be enabled in your php.ini file

To check for the presence of these extensions, you can run:

$ php -m

You should see a list of enabled PHP modules.

Advanced Considerations

As you get more comfortable with Laravel, you may consider:

  • Setting up a virtual host for your application
  • Exploring different development environments like Docker or Laravel Valet (Mac-specific)
  • Utilizing Laravel Homestead, a pre-packaged Vagrant box that provides a standardized development environment

These advanced configurations can help streamline your development process, especially as your projects become more complex.

Conclusion

Throughout this guide, we’ve established the steps to install Laravel on both Windows and Mac platforms. By following these instructions, you should have a running Laravel development environment and be prepared to build modern PHP web applications. As with any development tool, the real learning comes with creating projects, so go ahead and start building!