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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners