Laravel Framework Reference Guide

Quick reference guide for the Laravel framework — query builder, Eloquent, controllers, and more.

These notes are written for anyone who's used Laravel before and needs a fast reminder of syntax, rather than a first introduction to the framework. Each topic below is a self-contained page with runnable code examples, organised by category so related concepts sit together. They lean on the official Laravel documentation for anything that needs the full detail, but cover enough on their own that you shouldn't need to leave the page for common tasks.

Why Laravel

Laravel is a PHP framework built around convention over configuration: routing, the ORM, validation, queues, caching, and authentication are all provided out of the box and designed to work together, so a new project gets a consistent structure without much upfront decision-making. That's the main appeal over assembling a stack from individual PHP libraries — less boilerplate and fewer integration decisions, at the cost of some flexibility if a project's needs fall outside what the framework expects.

Eloquent, Laravel's ActiveRecord-style ORM, is usually the biggest single reason developers pick it over a plain PHP or a leaner framework like Slim. Relationships, eager loading, query scopes, and model events cover most of what an application needs from its database layer without writing raw SQL, and the same fluency carries through to migrations, form validation, and the templating engine (Blade). The trade-off is a heavier framework with more moving parts than a minimal router-plus-database-layer setup, which matters for very small scripts but pays off quickly once an application grows past a handful of routes.

Starting a new project

composer create-project laravel/laravel PROJECTNAME
cd PROJECTNAME

Authentication scaffolding — pick one

Laravel Breeze — lightweight, modern, easiest to customise. Blade views only (no Vue/React), so the Node build tooling can be stripped out afterwards.

composer require laravel/breeze --dev
php artisan breeze:install blade
rm -rf node_modules package.json package-lock.json vite.config.js
php artisan migrate

Laravel UI + Bootstrap — older-style scaffolding, matches this project's own login/register modals.

composer require laravel/ui
php artisan ui bootstrap --auth

Further viewing

Cloning an existing Laravel repo

Starting from an existing repo — a starter kit, or just a project you're picking up — skips composer create-project entirely, but needs a few extra steps before the app will actually boot, since none of the environment-specific files (.env, the app key, vendor/) are committed to git in the first place.

git clone https://github.com/<owner>/<repo-name>.git
cd <repo-name>

composer install

cp .env.example .env
php artisan key:generate

php artisan migrate

composer install reads composer.lock to rebuild the exact vendor/ directory the repo was built against — it's git-ignored, so nothing will run without this step. .env is git-ignored too (it holds secrets like database credentials and API keys), which is why every setup guide starts by copying .env.example as a template and generating a fresh APP_KEY with key:generate rather than reusing whatever key happens to be committed to a template repo. Point the DB_* variables in .env at a real database before running migrate, or it'll fail trying to connect.

This site's own Laravel Bootstrap Starter Kit follows exactly this flow — a bare Laravel install pre-wired with Bootstrap styling and no Node/Vite build step to worry about. On GitHub, clicking Use this template → Create a new repository instead of forking gives a clean new repo with its own history, rather than one carrying the starter kit's commit log along with it.