Laravel + Postgres, Dockerized
A hands-on refresh for shipping Laravel in Docker with a Postgres database: how the containers fit together, how a request flows through routes and controllers, and how migrations and Eloquent model your data. Real config and PHP to read, plus a runnable model of each concept.
4 lessons · ~1.5 hours
1. Laravel in a Container
The Dockerized setup
Three containers — app, database, web — wired together with Compose. See how they depend on and find each other.
Routes & controllers
A URL maps to a controller method. Follow the request from route definition to a typed parameter.
Migrations & Eloquent
Define your Postgres schema in versioned migrations, then read and write it with Eloquent models.
Relationships & queries
Connect tables with hasMany/belongsTo, then build queries fluently — and avoid the N+1 trap.