> ## 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 on WSL (Windows)

> A step-by-step guide to setting up a Laravel development environment on Windows 10/11 by installing PHP, Composer, and Node.js on WSL 2.

## Introduction

The best practice for developing Laravel on Windows is to use **WSL (Windows Subsystem for Linux)**. Because you can use the Linux toolchain as-is, the same commands work as on macOS and production servers.

This guide walks through installing PHP, Composer, and Node.js (via nvm) on Ubuntu under WSL 2, getting you to a state where `laravel new` works.

<Info>
  Target environment: Windows 10 (version 2004 or later) or Windows 11. WSL 2 is used.
</Info>

***

## Installing WSL

<Steps>
  <Step title="Open PowerShell as administrator">
    Search "PowerShell" in the start menu and select "Run as administrator."
  </Step>

  <Step title="Install WSL and Ubuntu">
    ```powershell theme={null}
    wsl --install
    ```

    This command installs WSL 2 and Ubuntu (the default distribution). Restart the PC when it's done.
  </Step>

  <Step title="Set up Ubuntu">
    After the restart, Ubuntu launches automatically. Set a username and password. This password is used for the `sudo` command.

    <Warning>
      The password won't appear on screen as you type. Enter it accurately.
    </Warning>
  </Step>

  <Step title="Update the package list">
    Run the following in the Ubuntu terminal.

    ```bash theme={null}
    sudo apt update && sudo apt upgrade -y
    ```
  </Step>
</Steps>

***

## Installing PHP

The PHP shipped in Ubuntu's default repository can be an older version. Install the latest version using the `ondrej/php` PPA.

<Steps>
  <Step title="Install required packages">
    ```bash theme={null}
    sudo apt install -y software-properties-common
    ```
  </Step>

  <Step title="Add the ondrej/php PPA">
    ```bash theme={null}
    sudo add-apt-repository ppa:ondrej/php
    sudo apt update
    ```
  </Step>

  <Step title="Install PHP 8.3 and required extensions">
    Laravel 13 requires PHP 8.3 or later.

    ```bash theme={null}
    sudo apt install -y php8.3 php8.3-cli php8.3-mbstring php8.3-xml php8.3-curl php8.3-zip php8.3-sqlite3 php8.3-mysql
    ```
  </Step>

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

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

  <Step title="(Optional) Switching between multiple versions">
    If you need multiple PHP versions, switch with `update-alternatives`.

    ```bash theme={null}
    sudo update-alternatives --config php
    ```

    A list of installed versions appears; enter the number of the one you want to use.
  </Step>
</Steps>

***

## Installing Composer

Install Composer using the official installer.

<Steps>
  <Step title="Verify required packages">
    ```bash theme={null}
    sudo apt install -y curl php8.3-cli unzip
    ```
  </Step>

  <Step title="Download and run the official installer">
    ```bash theme={null}
    curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
    sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=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 `~/.bashrc` (or `~/.zshrc`):

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

    Apply the changes.

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

***

## Installing nvm

Install Node.js on a per-user basis with nvm (Node Version Manager). Because it doesn't require `sudo`, 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 `~/.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"
    ```

    Apply the changes.

    ```bash theme={null}
    source ~/.bashrc
    ```

    If you use zsh, add the same to `~/.zshrc` and apply with `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 Windows browser; if the Laravel welcome page appears, you're done.

    <Tip>
      If you can't reach `localhost` from a Windows browser under WSL, try running it with `php artisan serve --host=0.0.0.0`.
    </Tip>
  </Step>
</Steps>

***

## Extras: tools to improve productivity

### Windows Terminal

Windows Terminal lets you manage WSL, PowerShell, and Command Prompt together in tabs. It's free from the Microsoft Store.

* Operate multiple shells in parallel with tabs
* Set the Ubuntu shell as the default
* Freely customize fonts and colors

### VS Code Remote - WSL extension

With the [Remote - WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension for VS Code, you can edit files inside WSL directly from VS Code on Windows.

```bash theme={null}
# Open the project in VS Code from the WSL terminal
code .
```

On first run, the VS Code server is installed automatically inside WSL. From then on, development feels native.


## Related topics

- [Installing PHP, Composer, and Node.js with Homebrew (macOS)](/en/blog/mac-setup.md)
- [Laravel Boost Custom Agent for PhpStorm with GitHub Copilot](/en/packages/laravel-boost-phpstorm-copilot.md)
- [Installation](/en/installation.md)
- [Mail](/en/mail.md)
- [Laravel Boost Custom Agent for GitHub Copilot CLI](/en/packages/laravel-boost-copilot-cli.md)
