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
- Typed Properties:
public string $name; - Constructor Promotion:
public function __construct(public string $name) {} - Union Types:
public function find(int|string $id) - Match Expressions: A cleaner
switchstatement. - Readonly Classes: Immutable data objects (DTOs).
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
- Open your terminal (WSL2 on Windows, or native Terminal on Mac/Linux).
- Run:
curl -s "https://laravel.build/laravel-senior-app?with=mysql,redis" | bash - Navigate to the folder:
cd laravel-senior-app - 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.
- Create a class
UserData. - It should be a readonly class.
- Use Constructor Property Promotion.
- Properties:
name(string)email(string)role(Enum: 'Admin', 'User') - Create a PHP Enum for this.
- Add a method
toArray()that returns an associative array.
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
.envfile exists. - Ensure
DB_CONNECTION=mysqlandREDIS_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:
- Add
declare(strict_types=1);to the top of your file. - Type hint the function:
function add(int $a, int $b): int. - Observe the error when passing a string. This is how we prevent bugs in Enterprise apps.