Create a New Laravel 13 Project in 2026 - Step-by-Step with Docker and Composer

Create a New Laravel 13 Project in 2026 - Step-by-Step with Docker and Composer

If you want to create a Laravel project in 2026, the fastest reliable path is Laravel 13 + Docker + MySQL 8. This guide gives you a clean, repeatable setup for local development and a strong foundation for production.

By the end, you will have:

  • A fresh Laravel 13 app.
  • A Docker-based local environment.
  • MySQL 8 wired and tested.
  • A baseline structure ready for real feature work.

Prerequisites

Before creating the project, install the following:

  • PHP 8.3+ (CLI).
  • Composer 2.x.
  • Docker Desktop.
  • Git.

You can verify quickly:

php -v
composer -V
docker --version
git --version

Step 1: Create the Laravel 13 project

If you have the Laravel installer, use laravel new first:

laravel new laravel-starter

If you are not using the Laravel installer, use Composer as an alternative:

composer create-project laravel/laravel laravel-starter

Move into the project:

cd laravel-starter

Confirm the framework version:

php artisan --version

Step 2: Start with Laravel Sail (Docker)

Laravel Sail gives you an official Docker workflow without manually building every container from scratch.

Install Sail dependencies and publish Docker files:

composer require laravel/sail --dev
php artisan sail:install --with=mysql,redis,mailpit

Bring containers up:

./vendor/bin/sail up -d

To simplify commands, add an alias:

alias sail='sh $([ -f sail ] && echo sail || echo vendor/bin/sail)'

Then use:

sail artisan about

Step 3: Configure .env for MySQL 8

After Sail install, your .env is mostly ready. Confirm key values:

APP_NAME="Laravel Starter"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=sail
DB_PASSWORD=password

Why DB_HOST=mysql? In Docker networking, mysql is the service hostname defined by Sail.

Step 4: Generate app key and run migrations

Run initial setup commands inside Sail:

sail artisan key:generate
sail artisan migrate

If migrations succeed, your Laravel app is correctly connected to MySQL 8.

Step 5: Validate your app works end to end

Open the app:

http://localhost

Run tests:

sail test

Check queue worker quickly (optional):

sail artisan queue:work --once

At this point, you have a healthy Laravel 13 project baseline.

Step 6: Create a production-friendly folder structure

A useful early pattern is to keep business logic out of controllers.

Suggested starter layout:

app/
  Actions/
  Services/
  Repositories/
  Http/Controllers/
  Http/Requests/

Keep it lightweight at first. Add layers only when they help clarity.

Step 7: Add quality defaults early

Install tools you will almost certainly need:

sail composer require laravel/pint --dev
sail composer require pestphp/pest --dev
sail artisan pest:install

Add a basic format-and-test routine:

sail pint
sail test

Starting clean prevents style drift as the project grows.

Step 8: Add your first feature route and controller

Create a simple health endpoint so you can validate deploys later:

sail artisan make:controller HealthController

routes/web.php:

use App\Http\Controllers\HealthController;
use Illuminate\Support\Facades\Route;

Route::get('/health', HealthController::class);

app/Http/Controllers/HealthController.php:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Response;

class HealthController extends Controller
{
    public function __invoke(): Response
    {
        return response('ok', 200);
    }
}

Now http://localhost/health should return ok.

Common setup mistakes (and fast fixes)

ProblemCauseFix
SQLSTATE[HY000] [2002] Connection refusedWrong DB host in DockerUse DB_HOST=mysql
No application encryption key has been specifiedMissing app keyRun sail artisan key:generate
Class "PDO" not foundPHP extension mismatchUse Sail PHP container, not host PHP
App runs, migrations failContainers not fully upWait a few seconds, then retry migrations
Slow first loadCold Docker buildNormal on first boot; improves after image cache

Docker-based workflow cheatsheet

# Start containers
sail up -d

# Stop containers
sail down

# Run migrations
sail artisan migrate

# Run tests
sail test

# Run queue worker
sail artisan queue:work

# Open shell in app container
sail shell

Why this setup works in 2026

  • Docker keeps developer machines consistent.
  • Laravel Sail stays close to Laravel defaults.
  • MySQL 8 gives predictable SQL behavior for modern apps.
  • Composer-based bootstrap keeps onboarding simple for teams.

This gives you a project that is easy to run, easy to hand off, and ready for CI/CD.

FAQ

Should I use Sail or run PHP directly on my machine?

For solo experiments, either works. For team projects and predictable onboarding, Sail is usually better.

Do I need Redis on day one?

Not mandatory, but enabling it early is useful for queues, caching, and later scaling.

Can I switch from MySQL to PostgreSQL later?

Yes, but database-specific SQL and indexes may need updates. If you expect a switch, avoid engine-specific behavior early.

Is this setup production-ready?

It is production-minded, not production-complete. You still need deployment, monitoring, backups, and security hardening.

Final takeaway

If your goal is to create a Laravel project quickly without sacrificing quality, use Laravel 13 with Sail, Docker, and MySQL 8. You will move faster now and avoid painful environment mismatches later.

Next in this series: How to Run Raw SQL Queries in Laravel with DB::raw and the upcoming Laravel .env guide.