> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Installing PHP, Composer, and Node.js with Homebrew (macOS)

> A step-by-step guide to setting up a Laravel development environment on macOS by installing PHP, Composer, and Node.js via Homebrew.

## Introduction

The Laravel team provides [Herd](https://herd.laravel.com/) and `php.new` for beginners, but senior engineers tend to prefer managing each tool individually via a package manager. You can control versions yourself and easily switch between different PHP versions across projects.

This guide walks through installing PHP, Composer, and Node.js (via nvm) with **Homebrew**, getting you to a state where `laravel new` works.

<Info>
  Target environment: macOS 13 Ventura or later. Works on both Apple Silicon (M1/M2/M3) and Intel.
</Info>

***

## Installing Homebrew

Homebrew is a package manager for macOS. If you haven't installed it, run the following in your terminal.

```bash theme={null}
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

After installation, on Apple Silicon the following line is automatically added to a shell profile such as `~/.zprofile`. If you added it manually, reload the settings.

```bash theme={null}
eval "$(/opt/homebrew/bin/brew shellenv)"
```

Verify the installation.

```bash theme={null}
brew --version
```

***

## Installing PHP

<Steps>
  <Step title="Install the latest PHP">
    Homebrew's `php` formula always points at the latest stable version. Laravel 13 requires PHP 8.3 or later.

    ```bash theme={null}
    brew install php
    ```
  </Step>

  <Step title="Check the version">
    ```bash theme={null}
    php --version
    ```

    Success looks like `PHP 8.3.x` or later.
  </Step>

  <Step title="(Optional) Use a specific version">
    To manage multiple PHP versions, install a versioned formula.

    ```bash theme={null}
    brew install php@8.3
    ```

    Switch versions with `brew link`.

    ```bash theme={null}
    brew unlink php
    brew link php@8.3 --force --overwrite
    ```

    Check the currently linked version.

    ```bash theme={null}
    php --version
    ```
  </Step>
</Steps>

***

## Installing Composer

<Steps>
  <Step title="Install Composer">
    Install directly with Homebrew.

    ```bash theme={null}
    brew install composer
    ```
  </Step>

  <Step title="Check the version">
    ```bash theme={null}
    composer --version
    ```
  </Step>

  <Step title="Configure the path for global installs">
    So that packages installed with `composer global require` (like the Laravel installer) are usable, add `~/.composer/vendor/bin` to your `PATH`.

    Append this to `~/.zshrc` (or `~/.bashrc`):

    ```bash theme={null}
    export PATH="$HOME/.composer/vendor/bin:$PATH"
    ```

    Apply the changes.

    ```bash theme={null}
    source ~/.zshrc
    ```
  </Step>
</Steps>

***

## Installing nvm

Install Node.js on a per-user basis using nvm (Node Version Manager). Because it doesn't require `root`, it plays nicely with AI tools and CLIs that use global npm packages.

<Steps>
  <Step title="Install nvm">
    The latest install script is available on [nvm's GitHub repository](https://github.com/nvm-sh/nvm).

    ```bash theme={null}
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
    ```
  </Step>

  <Step title="Add to your shell config">
    The install script automatically appends the following to `~/.zshrc` (or `~/.bashrc`). Add it manually if it isn't already there.

    ```bash theme={null}
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
    ```

    Reload the settings.

    ```bash theme={null}
    source ~/.zshrc
    ```
  </Step>

  <Step title="Verify the installation">
    ```bash theme={null}
    nvm --version
    ```
  </Step>
</Steps>

***

## Installing Node.js

<Steps>
  <Step title="Install the LTS version">
    ```bash theme={null}
    nvm install --lts
    ```
  </Step>

  <Step title="Set as default">
    Set the default version so it's used automatically in new terminal sessions.

    ```bash theme={null}
    nvm alias default node
    ```
  </Step>

  <Step title="Check the versions">
    ```bash theme={null}
    node --version
    npm --version
    ```
  </Step>
</Steps>

***

## Verifying the Laravel installation

<Steps>
  <Step title="Install the Laravel installer">
    ```bash theme={null}
    composer global require laravel/installer
    ```
  </Step>

  <Step title="Create a new project">
    ```bash theme={null}
    laravel new my-app
    ```

    An interactive setup begins. You can choose a starter kit and whether to include authentication.
  </Step>

  <Step title="Start the dev server">
    ```bash theme={null}
    cd my-app
    php artisan serve
    ```

    Open `http://localhost:8000` in a browser; if the Laravel welcome page appears, you're done.
  </Step>
</Steps>

***

## When to use Herd

|                            | Manual Homebrew setup                                            | Herd                                                     |
| -------------------------- | ---------------------------------------------------------------- | -------------------------------------------------------- |
| **Target audience**        | Developers who want fine control over versions and configuration | Beginners and indie developers who want to start quickly |
| **Switching PHP versions** | Manually with `brew link`                                        | Easy switching via GUI                                   |
| **Local domains**          | Manually edit `/etc/hosts`                                       | `.test` domains configured automatically                 |
| **Service management**     | `brew services`                                                  | Start and stop from the GUI                              |
| **Customization**          | High                                                             | Limited                                                  |

Manual setup with Homebrew is a good fit if you want to match settings with team members and CI environments, or if you frequently switch between multiple PHP versions.


## Related topics

- [Installing PHP, Composer, and Node.js on WSL (Windows)](/en/blog/windows-setup.md)
- [Installation](/en/installation.md)
- [Upgrade guide: Laravel 11 to 12](/en/blog/upgrade-11-to-12.md)
- [Guide to Building Apps with VOICEVOX Engine API](/en/packages/laravel-voicevox/app-guide.md)
- [Laravel Sail](/en/sail.md)
