Module 1: Modern PHP & Setup

PHP 8.2+, Docker (Sail), and Environment Configuration.

1. Modern PHP (8.2+)

Laravel 12 requires modern PHP. If you are still writing PHP 5 or 7 style code, you need to upgrade your mental model.

Key Features to Master

2. The Environment (Docker/Sail)

The job requires knowledge of Linux, Nginx, MySQL, and Redis. The best way to simulate this locally is using Laravel Sail, which wraps Docker.

Task: Initialize the Project

  1. Open your terminal (WSL2 on Windows, or native Terminal on Mac/Linux).
  2. Run: curl -s "https://laravel.build/laravel-senior-app?with=mysql,redis" | bash
  3. Navigate to the folder: cd laravel-senior-app
  4. Start the environment: ./vendor/bin/sail up -d

Note: This sets up a containerized environment with PHP, MySQL, and Redis, matching the job requirements.

3. The Build Challenge: "Strict DTO"

Requirements

Create a plain PHP class (no Laravel yet) to demonstrate PHP 8.2 mastery.

INFRA-001 Configuration

Database & Redis Configuration

User Story

As a DevOps engineer, I need the application to connect to MySQL and Redis using environment variables.

Acceptance Criteria
  • Verify .env file exists.
  • Ensure DB_CONNECTION=mysql and REDIS_CLIENT=phpredis.
  • Challenge: Connect to the running MySQL container using a GUI tool (TablePlus, DBeaver) using the credentials in .env.

4. The Bug Hunt

🐛 Scenario: The Loose Type

The Setup:

function add($a, $b) {
    return $a + $b;
}
echo add("5 dogs", 10); // PHP used to allow this!

The Bug: In older PHP, this might output 15 with a warning. In PHP 8+, this is a TypeError or ValueError depending on strictness.

The Task:

  1. Add declare(strict_types=1); to the top of your file.
  2. Type hint the function: function add(int $a, int $b): int.
  3. Observe the error when passing a string. This is how we prevent bugs in Enterprise apps.