How to Install Laravel
By Pawan Singh · Jun 2026
Installing Laravel itself takes two minutes. Getting a properly configured, ready-to-develop-in app takes a bit more — this walks through both, plus the environment and database decisions worth making up front rather than fixing later.
Requirements
Laravel is a PHP framework, so the requirements are really PHP's requirements. As of Laravel 11 and 12, you need:
- PHP 8.2 or higher
- Composer 2.x (PHP's dependency manager)
- The PHP extensions Laravel depends on: Ctype, cURL, DOM, Fileinfo, Filter, Hash, Mbstring, OpenSSL, PCRE, PDO, Session, Tokenizer, and XML
- Node.js and npm (for compiling front-end assets with Vite)
Most of these extensions ship enabled by default on Linux and macOS PHP builds. The ones people actually trip over are pdo_mysql/pdo_sqlite (needed for the database you pick) and, occasionally on Windows, fileinfo. Run php -m to see what's already enabled before assuming something is missing.
Two Ways to Create a New Project
Both do the same thing under the hood — pick whichever is already on your machine.
Composer's create-project needs nothing pre-installed beyond Composer itself:
composer create-project laravel/laravel example-app
The Laravel installer is a small global tool that adds a few conveniences (starter kit prompts, a nicer new-project wizard):
composer global require laravel/installer
laravel new example-app
Either way, this pulls the latest stable Laravel release into an example-app directory and installs every dependency listed in composer.json automatically. If you already have an existing project (cloned from Git rather than created fresh), skip straight to running composer install instead — that's covered in more detail in a separate walkthrough of Composer install specifically.
Choosing a Database
Laravel defaults new projects to SQLite, which is the fastest way to get moving locally — no server process, no credentials, just a file:
touch database/database.sqlite
Set DB_CONNECTION=sqlite in .env and you're done; Laravel doesn't need a host, username, or password for SQLite. For anything closer to a production setup — or if your team already standardizes on MySQL, MariaDB, or PostgreSQL — set the connection accordingly and fill in DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD instead. There's no wrong choice for local development; SQLite is simply less setup.
Configure Your Environment
Laravel ships with a .env.example template. Copy it and generate the application encryption key:
cp .env.example .env
php artisan key:generate
APP_KEY is used to encrypt session data and signed URLs — the app will refuse to run without one. While you're in .env, it's worth setting APP_URL to match wherever you'll actually be viewing the site (this affects generated absolute URLs, e.g. in emails), and confirming APP_ENV=local and APP_DEBUG=true for development so you get full error pages instead of generic 500s.
Run Database Migrations
php artisan migrate
This creates the tables Laravel's defaults expect (users, cache, jobs, etc.) plus anything your own migration files define. If you want the database populated with sample data too, pair it with a seeder run: php artisan migrate --seed.
Install Front-End Dependencies
Even a backend-only API project includes a minimal Vite setup for the default welcome page and any Blade views. Install and build it with:
npm install
npm run dev
Leave npm run dev running in a separate terminal while you work — it watches for changes and hot-reloads compiled assets. Use npm run build instead when you actually want a production-ready bundle.
Start the Development Server
php artisan serve
Visit http://localhost:8000 to see the default Laravel welcome page. artisan serve is fine for quick local checks, but it's a single-threaded PHP built-in server — for anything closer to a real environment (multiple services, HTTPS locally, matching PHP versions across a team), Laravel Sail (a thin Docker Compose wrapper Laravel ships with) or a tool like Herd/Valet on macOS is worth setting up instead of relying on artisan serve long-term.
A Quick Tour of the Directory Structure
app/— your application code: models, controllers, providers, middlewareroutes/—web.phpfor browser routes,api.phpfor stateless API routesdatabase/— migrations, factories, seeders, and the SQLite file if you're using oneresources/— Blade views and front-end assets (JS/CSS) that Vite compilesconfig/— one file per subsystem (database, cache, mail, etc.), mostly reading from.envstorage/— logs, compiled views, file uploads, and framework cache — must be writable by the web server
Common Issues
- Composer not found — install it globally from getcomposer.org and confirm it's on your
PATHwithcomposer --version. - "Your requirements could not be resolved" during install — usually a PHP version mismatch between what your CLI runs (
php -v) and what Laravel'scomposer.jsonrequires; check both, since it's common to have two PHP versions installed side by side. - Permission errors on
storage/andbootstrap/cache/— these need to be writable by whatever user your web server runs as; on shared hosting this is often a group-permission issue rather than a missing chmod. - "No application encryption key has been specified" — you skipped (or the copy of
.envfailed before)php artisan key:generate. - Class not found errors after adding new classes manually — run
composer dump-autoloadto regenerate Composer's class map. - Blank white page with no error — set
APP_DEBUG=truein.envtemporarily and checkstorage/logs/laravel.log, which almost always has the real exception even when the browser shows nothing.
Need help setting up or building a Laravel application? I work as a freelance Laravel developer — get in touch.