Web Development

How to Install Laravel on macOS with XAMPP (Step-by-Step Guide)

Saranath Ishara Udayanga

Saranath Ishara Udayanga

Published on December 09, 2025

How to Install Laravel on macOS with XAMPP (Step-by-Step Guide)

If you have already set up XAMPP on your Mac and are ready to take the next step into modern PHP development, installing Laravel is the perfect move. Laravel is one of the most popular PHP frameworks, but setting it up locally can sometimes be tricky.

In this guide, we will walk you through exactly how to install Composer, set up a new Laravel project inside XAMPP, and run your first application.

Prerequisites

Before we begin, ensure you have XAMPP installed and running on your macOS system. If you haven't installed it yet, you'll need to do that first.

Step 1: Download and Install Composer

Laravel requires Composer, a dependency manager for PHP, to manage its libraries.

  1. Open your browser and navigate to getcomposer.org 

  2. Click on the Download button.

  3. You will see a block of command-line code. Copy these commands and paste them into your terminal one by one to download the installer and verify it 

  4. Once the download is complete, you should see a composer.phar file in your directory.

Step 2: Make Composer Globally Accessible

By default, Composer might only be installed locally. To use the composer command from anywhere in your terminal, you need to move it to your system's global bin directory.

Run the following command in your terminal:

sudo mv composer.phar /usr/local/bin/composer

Note: You may be asked to enter your Mac user password .

To verify the installation, type composer in your terminal. If you see the Composer logo and version details (e.g., version 2.x), you are good to go .

Step 3: Create a Laravel Project in XAMPP

Now that Composer is ready, let's install Laravel. We want to install it inside the XAMPP htdocs folder so that the Apache server can serve it.

  1. Navigate to the XAMPP directory: In your terminal, change your directory to the XAMPP web root:

  2. Run the Installation Command: Go to the Laravel documentation or simply use the create-project command. Replace laravel-example with your desired project name:

composer create-project laravel/laravel laravel-example

Composer will now download all the necessary files and dependencies

  1. Run Your Laravel Application

    There are two ways to view your new Laravel site:

Option A: Using PHP Artisan (Built-in Server)

This is the quickest way to test if your installation worked.

    1. Navigate into your new project folder:

cd laravel-example

     2. Start the development server: 

         php artisan serve

Open your browser and go to the URL provided (usually http://127.0.0.1:8000) . You should see the default Laravel welcome page.

Share this post:

Related Posts

Comments (0)

No comments yet. Be the first to share your thoughts!

Leave a Comment

Please sign in with Google to leave a comment.