Introduction
Before writing a single route you need PHP, Composer, the Laravel installer, and Node.js on your machine. This lesson walks you through the one-command installers for macOS, Windows, and Linux, plus the all-in-one Laravel Herd option.
Key Concepts
- PHP: The runtime Laravel executes on. Laravel 13 requires PHP 8.3 or higher.
- Composer: PHP's package manager — Laravel and its dependencies are installed through it.
- Laravel installer: A global Composer package that adds the
laravel newcommand. - Node.js / Bun: Needed to bundle frontend assets with Vite.
- Laravel Herd: An all-in-one macOS/Windows environment that bundles PHP, Nginx, and databases.
Real World Context
Onboarding a new teammate to a Laravel project used to take half a day. Modern installers (php.new, Herd) cut that to minutes — a fresh laptop can run laravel new before the coffee is ready.
Deep Dive
Before creating Laravel applications, you need to install PHP, Composer, and the Laravel installer. Let's get everything ready for development.
Prerequisites
Laravel 13 requires:
- PHP 8.3 or higher (we recommend PHP 8.4)
- Composer (PHP package manager)
- Node.js and NPM (for frontend assets)
- A code editor (VS Code, PhpStorm, or Cursor)
Step 1: Install PHP and Composer
The easiest way to install PHP, Composer, and the Laravel installer is using the official installation scripts.
On macOS
bash/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)"
This installs:
- PHP 8.4
- Composer
- Laravel installer
Restart your terminal after installation.
On Windows (PowerShell as Administrator)
powershellSet-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
On Linux (Ubuntu/Debian)
bash/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
Verify Installation
bash# Check PHP version php --version # PHP 8.4.x # Check Composer composer --version # Composer version 2.x.x # Check Laravel installer laravel --version # Laravel Installer x.x.x
Step 2: Install Node.js
Laravel uses Vite for frontend asset compilation. You need Node.js:
Using the Official Installer
Download from https://nodejs.org (LTS version recommended)
Using nvm (Node Version Manager) - Recommended
bash# Install nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash # Install Node.js nvm install --lts # Verify node --version npm --version
Alternative: Using Bun
Laravel also supports Bun as a faster alternative:
bashcurl -fsSL https://bun.sh/install | bash
Step 3: Choose a Code Editor
We recommend these editors for Laravel development:
VS Code / Cursor
Install these extensions:
- PHP Intelephense - Smart PHP support
- Laravel Extension Pack - Blade, Artisan, and more
- Laravel Blade Snippets - Blade template support
- DotENV - Environment file syntax
PhpStorm
PhpStorm has excellent built-in Laravel support including:
- Blade template support
- Eloquent model autocompletion
- Route and view navigation
- Artisan command integration
Alternative: Laravel Herd
Laravel Herd is an all-in-one development environment that includes PHP, Nginx, and more.
On macOS
- Download from https://herd.laravel.com
- The installer sets up everything automatically
- Applications in
~/Herdare served on.testdomains
bashcd ~/Herd laravel new my-app cd my-app herd open # Opens http://my-app.test in browser
On Windows
- Download Herd for Windows
- Applications go in
%USERPROFILE%\Herd - Same
.testdomain feature
Troubleshooting
"php: command not found"
Restart your terminal or add PHP to your PATH.
"Permission denied" on macOS/Linux
Don't use sudo with Composer. Fix permissions instead:
bashsudo chown -R $USER ~/.composer
Composer memory errors
Increase memory limit:
bashCOMPOSER_MEMORY_LIMIT=-1 composer install
Common Pitfalls
- Using
sudo composer— It breaks file permissions under your home directory. Fix permissions withchown -R $USER ~/.composerinstead. - Installing PHP from multiple sources — Running a Homebrew PHP alongside Herd's PHP leads to version confusion. Pick one and stick with it.
Best Practices
- Match PHP versions to Laravel — Laravel 13 needs 8.3+. Run
php --versionbefore you start and upgrade if needed. - Use Herd on macOS/Windows — It saves you hours of manual nginx, database, and DNS wiring.
Summary
- Laravel 13 requires PHP 8.3 or higher.
- Composer installs Laravel and its dependencies.
- The
laravel newinstaller is the fastest way to start a project. - Node.js (or Bun) is needed to build frontend assets.
- Laravel Herd bundles everything on macOS and Windows.