Since its release in late 2020, PHP 8 has been a game changer. In this tutorial, I will walk through all the latest features with real-world examples of when I might choose to use them.

Let’s break it down: // Before PHP 8.0 class Client { private string $url; public function __construct(string $url) { $this->url = $url; }} class Client { public function __construct( private string $url, ) {}}

// Before PHP 8.1 class Method { public const GET = 'GET'; public const POST = 'POST'; public const PUT = 'PUT'; public const PATCH = 'PATCH'; } enum Method: string { case GET = 'GET'; case POST = 'POST'; case PUT = 'PUT'; case PATCH = 'PATCH'; }

// Before PHP 8.1 class Post { public function __construct() { protected string $title, protected string $content, } public function getTitle(): string { return $this->title; } public function getContent(): string { return $this->content; }} class Post { public function __construct() { public readonly string $title, public readonly string $content, }}
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners