Programming

How to Install Laravel PHP Framework

You run composer create-project, wait three minutes, and get a wall of red text about a missing PHP extension. Or the install works, but laravel isn't recognized, or the page at localhost shows a database error. Most Laravel install problems come from the setup around the framework, not from Laravel itself.

Developer running install commands in a terminal to install Laravel on a laptop.

This guide shows how to install Laravel 13 on Windows, macOS and Linux with the current official method. It also covers the choices that confuse beginners (starter kits, SQLite versus MySQL), a table of the errors people hit most, and the steps to check that everything works.

Quick answer: To install Laravel 13, install PHP 8.3 or newer, Composer and the Laravel installer, then run laravel new example-app. Move into the folder, run npm install && npm run build, then composer run dev and open http://localhost:8000. New apps use SQLite by default, so no database setup is needed to start.

What You Need Before You Install Laravel

Laravel needs PHP, Composer and Node with npm. Laravel 13 supports PHP 8.3 to 8.5. Composer manages PHP packages, and Node compiles the frontend assets. A database server is optional, because new apps use SQLite out of the box.

ToolWhat it doesCheck it with
PHP 8.3 to 8.5 (Laravel 13)Runs the frameworkphp -v
ComposerInstalls PHP packagescomposer -V
Laravel installerCreates new apps with laravel newlaravel --version
Node and npm (or Bun)Builds frontend assets with Vitenode -v and npm -v

The PHP range comes from the Laravel release notes, which also show that Laravel 12 supports PHP 8.2 to 8.5. If you run an older PHP version, upgrade it first. A newer Laravel release won’t install on an unsupported PHP.

If you’re not sure whether Laravel or Composer is already on your machine, see how to check if Laravel is installed and how to check the Laravel version.

Which Laravel Install Method Should You Use?

Use the one-command installer from php.new if you have nothing installed. Use laravel new if PHP and Composer already work. Use Laravel Herd if you want a point-and-click local environment on macOS or Windows. Composer’s create-project also still works.

MethodBest forNeeds
php.new scriptA fresh machine with no PHP or ComposerA terminal and internet access
composer global require laravel/installerPHP and Composer already installedWorking PHP and Composer
Laravel HerdmacOS or Windows, no manual server setupHerd app
composer create-project laravel/laravelScripts and CI, or the classic methodWorking PHP and Composer

Step 1: Install PHP, Composer and the Laravel Installer

If you have none of them, run the php.new script for your operating system. It installs PHP, Composer and the Laravel installer in one go. Restart your terminal afterward so the new commands are available.

On macOS:

/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.5)"

On Linux:

/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.5)"

On Windows, open PowerShell as administrator and run:

Set-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.5'))

To update PHP, Composer and the installer later, run the same command again.

If PHP and Composer are already installed, add the Laravel installer with Composer:

composer global require laravel/installer

If you only need Composer, the Composer download page lists the command-line steps, and our guide to installing Composer for Laravel walks through it in detail.

Step 2: Create Your Laravel App

Create the app with one command. The installer asks you to choose a testing framework, a database and a starter kit. Pick the defaults if you’re learning, because you can add or change everything later.

laravel new example-app

Which Starter Kit Should You Pick?

Starter kits add login, registration, password reset and email verification. All the official kits use Laravel Fortify for authentication, and two-factor authentication is included. A starter kit is optional, and you can start from a fresh install.

KitFrontendChoose it if
LivewireLivewire 4, Tailwind, Flux UIYou mainly write PHP and Blade
ReactReact 19, TypeScript, Tailwind, InertiaYou want a React single-page app
VueVue 3, TypeScript, Tailwind, InertiaYou want a Vue single-page app
SvelteSvelte 5, TypeScript, Tailwind, InertiaYou want a Svelte single-page app

Each kit also comes in a WorkOS variant that adds social login, passkeys and single sign-on, but it needs a WorkOS account. If you don’t want a kit, choose none when asked.

The Classic Alternative

You can also create the project with Composer directly:

composer create-project laravel/laravel example-app

This creates the same base project without the installer prompts. Use it in scripts or when the Laravel installer isn’t available.

Step 3: Run the App

Move into the project, build the frontend assets, then start the dev command. It runs the local server, the queue worker and the Vite development server together.

cd example-app
npm install && npm run build
composer run dev

Open http://localhost:8000 in your browser. If you see the Laravel welcome page, the install worked. Press Ctrl + C in the terminal to stop everything.

For more on starting a project and what to do next, read how to start a Laravel project.

Step 4: Configure the .env File

Laravel keeps environment settings in a .env file in the project root. This file holds your app name, debug mode, database connection, mail settings and secrets. Never commit it to source control.

Set these first:

  • APP_NAME for your project name.
  • APP_ENV as local while you develop.
  • APP_DEBUG as true locally only. It must be false in production, because debug mode can expose configuration values to visitors.
  • DB_* values for your database.

SQLite Is the Default Database

A new app uses SQLite. Laravel creates database/database.sqlite and runs the initial migrations for you, so you can start without installing a database server. That keeps your first run simple.

Switch to MySQL

To use MySQL, create an empty database, then set these values in .env:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

Then run the migrations, which are required for any database other than SQLite:

php artisan migrate

If the command fails, the most common causes are a wrong password, a database that doesn’t exist yet, or a MySQL server that isn’t running. Fix those first.

Step 5: Learn the Laravel Folder Structure

A new Laravel project has a small set of folders you’ll use constantly. Knowing them saves time when you follow tutorials or read other people’s code.

FolderWhat lives there
appYour application logic, such as models and controllers
routesWeb and API route definitions
resourcesViews and frontend assets
databaseMigrations, factories and the SQLite file
configConfiguration files
publicThe web entry point, index.php, and built assets
storageLogs, cache and uploaded files

Point your web server at public. Never move index.php into the project root, because that exposes configuration files to the internet.

Install Laravel With Herd on macOS or Windows

Herd is a native PHP and Laravel environment for macOS and Windows that includes PHP and Nginx. It serves any app in its parked folder on a .test domain, so you don’t need to run a server command.

On macOS:

cd ~/Herd
laravel new my-app
cd my-app
herd open

On Windows, in PowerShell:

cd ~\Herd
laravel new my-app
cd my-app
herd open

Herd uses the directory name for the domain, so my-app opens at my-app.test. For local MySQL, PostgreSQL or Redis on macOS or Windows, Laravel’s docs point to Herd Pro or DBngin.

How to Verify the Installation

Check three things: the version, the command list and the welcome page. If all three work, your install is healthy. Run these commands from the project folder:

php artisan --version
php artisan list
php artisan about

php artisan --version shows the Laravel version, php artisan list shows every available Artisan command, and php artisan about prints a summary of the environment. Then open the welcome page at http://localhost:8000. Test the database by running php artisan migrate. If it finishes without errors, the connection is correct.

Common Laravel Installation Errors and Fixes

Most install errors come from the PATH, the PHP version or a missing extension. Read the first red line of the error, because it usually names the cause. The table below covers the ones people hit most.

ErrorLikely causeFix
composer: command not foundComposer isn’t installed or isn’t on your PATHInstall Composer, then restart the terminal
laravel: command not foundThe Composer global bin folder isn’t on your PATHAdd Composer’s global vendor/bin folder to your PATH, then restart the terminal
Composer says your PHP version doesn’t satisfy a requirementPHP is older than the Laravel version needsUpgrade PHP to a supported version
Missing extension errorA required PHP extension is disabledEnable it in php.ini, then restart
could not find driverThe PDO driver for your database is missingEnable pdo_mysql or pdo_sqlite in php.ini
Port 8000 already in useAnother process uses the portStop that process, or run php artisan serve --port=8001
Write permission errorsThe web server can’t write to storage or bootstrap/cacheMake both writable by the web server user

The PHP extensions Laravel 12 lists as required are Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer and XML. Check the Laravel deployment docs for the list that matches your version.

From Local Install to a Real Server

A local install is not a production setup. Before you deploy, set APP_DEBUG=false, point the web server at public, and make storage and bootstrap/cache writable. Run php artisan optimize during deployment to cache config, routes and views.

One catch: after you run config:cache, Laravel stops loading the .env file. Call env() only inside configuration files, because elsewhere it returns null. For a step-by-step deployment, read how to deploy a Laravel project on cPanel.

Which Laravel Version Should You Install?

Install the latest major version for new projects. Laravel 13 is current and supports PHP 8.3 to 8.5. Laravel 12 still gets security fixes until February 24, 2027, and bug fixes ended on August 13, 2026.

LaravelPHPReleasedBug fixes untilSecurity fixes until
118.2 to 8.4March 12, 2024September 3, 2025March 12, 2026
128.2 to 8.5February 24, 2025August 13, 2026February 24, 2027
138.3 to 8.5Q1 2026Q3 2027Q1 2028

Laravel 11 no longer receives security fixes. If you maintain an older app, plan an upgrade, and see how to upgrade Laravel 9 to 10 for the pattern. If you need a specific older version, our guide to installing Laravel 10 covers it.

What to Do After Installing Laravel

After the install, build something small. Add a route, a controller and a view, then connect a model to a table. How to use Laravel is a good next read. Add Laravel Debugbar to see queries and timings while you build. If you’re hiring for a bigger project, see the skills a dedicated Laravel developer needs or our Laravel development service.

FAQ

How do I install Laravel on Windows?

Open PowerShell as administrator and run the php.new Windows command, which installs PHP, Composer and the Laravel installer. Restart the terminal, then run laravel new example-app. Or install Laravel Herd for a point-and-click local setup.

What do I need to install Laravel?

You need PHP, Composer and Node with npm. Laravel 13 supports PHP 8.3 to 8.5. A database server isn’t required, because new apps use SQLite by default.

What is the difference between laravel new and composer create-project?

Both create a Laravel app. laravel new uses the Laravel installer and asks about a starter kit, a testing framework and a database. composer create-project laravel/laravel creates the base project without those prompts.

Which PHP version does Laravel 13 need?

Laravel 13 supports PHP 8.3 to 8.5, according to the Laravel release notes. Laravel 12 supports PHP 8.2 to 8.5. Check the release notes before installing on an older server.

Do I need MySQL to run Laravel?

No. New apps use SQLite by default and create database/database.sqlite for you. Switch to MySQL by changing the DB_* values in .env and running php artisan migrate.

Why does localhost:8000 not load?

The dev server may not be running, or another process may be using port 8000. Run composer run dev, and check the terminal for errors. If the port is busy, stop the other process or run php artisan serve --port=8001.

How do I check which Laravel version I have?

Run php artisan --version inside the project folder. It prints the framework version. For more detail, php artisan about shows the environment summary.

Should I use a starter kit?

Use one if you need login and registration right away. Livewire suits PHP and Blade developers, and React, Vue or Svelte suit JavaScript-driven apps. You can also start with none and add authentication later.

Can I install Laravel without Composer?

Not in a practical way. Laravel’s dependencies are managed by Composer, and the official installers use it. The php.new script installs Composer for you if you don’t have it.

Install Once, Then Build

The install is the easy part when PHP, Composer and your PATH are right. Use laravel new, keep the default SQLite database while you learn, and read the first line of any error.

Once the welcome page loads, stop tweaking the setup and build a feature. Which will you start with, a login system from a starter kit, or a small API of your own?

Leave a Reply

Your email address will not be published. Required fields are marked *

Share the article

Written By

Author Avatar

January 20, 2025

Hi there! I’m Ayesha Khan, a skilled content writer with a strong background in computer science. I specialize in transforming complex ideas into clear, engaging, and easy-to-understand content. With 10 years of experience working across different industries, I focus on delivering content that not only informs but also connects with readers. I’m passionate about writing and take pride in creating high-quality work that helps clients communicate their message effectively.