If you've been working with PHP and want to level up your development game, Laravel is the framework you need. It's elegant, powerful, and once you get it running, you'll wonder how you ever built without it. This guide walks you through everything — from installing the requirements to running your very first Laravel project.

No complicated jargon. Just clear, step-by-step instructions that actually work.

Prerequisites & Requirements

Before we install Laravel, your machine needs a few things set up. Think of these as the foundation — Laravel won't work without them.

PHP (version 8.1 or higher)

Laravel 11 requires PHP 8.1 minimum. To check if PHP is already installed on your system, open your terminal or command prompt and run:

php -v

You should see something like PHP 8.2.0. If you get an error or a lower version, you'll need to install or upgrade PHP first. On Windows, the easiest way is using XAMPP or Laragon. On Mac, use Homebrew. On Linux, use your package manager.

Composer

Composer is PHP's dependency manager — it's what actually downloads and manages Laravel for you. Check if it's installed:

composer -v

If it's not installed, head to getcomposer.org and download the installer for your OS. It's a straightforward one-time setup.

A Database

Laravel works with MySQL, PostgreSQL, SQLite, and more. For beginners, MySQL is the most common choice. If you're using XAMPP or Laragon, MySQL comes bundled in — you're already covered.

Quick Checklist

  • PHP 8.1 or higher ✓
  • Composer installed ✓
  • MySQL or another database ready ✓
  • A terminal or command prompt ✓

Step-by-step Installation

Now the fun part. Installing Laravel is actually much simpler than most people expect. You only need one command to get a brand new project.

Step 1 — Open Your Terminal

Navigate to the folder where you want to create your project. For example, if you keep your projects in a projects folder:

cd C:\projects

On Mac or Linux:

cd ~/projects

Step 2 — Create a New Laravel Project

Run this single command. Replace my-app with whatever you want to name your project:

composer create-project laravel/laravel my-app

Composer will now download Laravel and all its dependencies. This might take a minute or two depending on your internet speed. You'll see a lot of text flying by — that's completely normal.

Alternatively, if you have the Laravel installer set up globally, you can use:

laravel new my-app

Step 3 — Enter Your Project Folder

Once the installation is complete, move into your new project directory:

cd my-app

Step 4 — Start the Development Server

Laravel comes with a built-in development server. Start it with:

php artisan serve

You'll see this message in your terminal:

INFO  Server running on [http://127.0.0.1:8000].

Press Ctrl+C to stop the server

Now open your browser and go to http://127.0.0.1:8000 — you should see the Laravel welcome page. Congratulations, Laravel is running!

First Project Setup

A fresh Laravel install needs a little configuration before you can start building. Here's what to do right after installation.

The .env File

Your project folder contains a file called .env — this is your environment configuration file. Open it in your code editor. You'll see database settings near the top:

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

Update these values to match your local database setup. If you're using XAMPP with default settings, the username is root and the password is empty — which is exactly what's shown above.

Create Your Database

Go to your database tool (phpMyAdmin, TablePlus, or MySQL command line) and create a new database. Give it the same name you put in DB_DATABASE inside your .env file.

CREATE DATABASE laravel;

Run the Default Migrations

Laravel comes with some default database tables (users, password resets, etc.). Run this command to create them:

php artisan migrate

You'll see a list of migrations being run. Once done, check your database — the tables are there.

Generate an Application Key

If for any reason your .env doesn't have an APP_KEY set, run this:

php artisan key:generate

This key is used for encrypting session data and other secure values. It's auto-generated during composer create-project, but good to know about.

Your Project Structure at a Glance

Here are the folders you'll work with most often as a beginner:

  • app/Http/Controllers — Your controllers live here
  • resources/views — Your Blade HTML templates
  • routes/web.php — All your web routes defined here
  • database/migrations — Database table definitions
  • public — The only folder your web server should point to

Common Errors & Fixes

Even with a clean install, a few errors pop up all the time. Here are the most common ones and exactly how to fix them.

Error: "composer" is not recognized

This means Composer isn't installed or isn't in your system's PATH. Fix: reinstall Composer from getcomposer.org and make sure to check the "Add to PATH" option during installation on Windows. On Mac/Linux, follow the global install instructions on the site.

Error: PHP version too low

Your PHP version (7.x) does not satisfy requirements.

You need to upgrade PHP. On Windows with XAMPP, download the latest XAMPP version. On Mac with Homebrew:

brew install php

Error: SQLSTATE[HY000] — Access denied for user

This is a database credentials mismatch. Open your .env file and double-check DB_USERNAME and DB_PASSWORD. If you're on XAMPP, username is root and password should be empty (no value, just blank).

Error: No application encryption key

No application encryption key has been specified.

Easy fix — just run:

php artisan key:generate

Error: "Failed to open stream: Permission denied"

Laravel can't write to the storage folder. This usually happens on Mac/Linux. Fix it with:

chmod -R 775 storage bootstrap/cache

Error: Port 8000 already in use

Another process is already running on port 8000. Either stop that process, or run Laravel on a different port:

php artisan serve --port=8080

What's Next?

You now have a fully working Laravel installation. Here's what to explore next to keep the momentum going:

  • Learn Blade templating — Laravel's powerful HTML template engine
  • Understand Eloquent ORM — how Laravel talks to your database
  • Build your first CRUD application — Create, Read, Update, Delete
  • Explore Laravel Breeze — a ready-made authentication starter kit

Laravel has one of the best official documentations out there at laravel.com/docs — bookmark it, you'll refer to it constantly.

The hardest part is always getting started. You've done that. Now go build something.

Programming 8 Min read
You're done reading

Explore more from Zlvox

Browse all posts