Home Features Download Changelog Blog Contact / Support Privacy Policy Terms of Use
Login Register
Blog

PHP 8.2 New Features: What Every Laravel Developer Needs to Know in 2026

PHP Mar 26, 2026  ·  3 min read

All Posts
PHP 8.2 New Features: What Every Laravel Developer Needs to Know in 2026

PHP 8.2 ships with Larastack and brings powerful new features — readonly classes, DNF types, deprecated dynamic properties, and more. Here's what changed and how it affects your Laravel codebase.

PHP 8.2 Is the Version That Changes How You Write Code

PHP 8.2 ships with Larastack as the default runtime — and it's not just a maintenance release. It introduces features that meaningfully improve how you architect Laravel applications, enforce type safety, and write cleaner object-oriented code.

Here's a complete breakdown of what's new and why it matters for your day-to-day Laravel development.


Readonly Classes

PHP 8.1 introduced readonly properties on individual class members. PHP 8.2 goes further by allowing you to declare an entire class as readonly — every property automatically becomes immutable after construction.

This is a game-changer for Data Transfer Objects and Value Objects in Laravel:

readonly class CreateUserRequest { public function __construct( public string $name, public string $email, public string $password, ) {} }

No more manually adding readonly to every single property. Declare it once at the class level and every property is protected.


Disjunctive Normal Form (DNF) Types

PHP 8.2 introduces DNF types, allowing you to combine union types and intersection types in a single declaration:

function processService(DatabaseService&Loggable|null $service): void { // accepts a DatabaseService that's also Loggable, or null }

This brings significantly more expressive power to type declarations in complex service layers and repository patterns.


true, false, and null as Standalone Return Types

Previously, true, false, and null could only be used as part of union types. In PHP 8.2 they work as standalone return type declarations:

function isFeatureEnabled(): true|false { ... } function getDeletedAt(): null { ... }

This makes intent clearer and enables better static analysis with tools like PHPStan and Psalm.


Deprecated Dynamic Properties

In PHP 8.2, adding properties to an object that weren't explicitly declared in the class body now generates a deprecation notice. In PHP 9.0, this will become a fatal error.

If you have legacy Laravel code that sets dynamic properties on Eloquent models or plain PHP objects, now is the time to refactor. Use proper property declarations or the #[AllowDynamicProperties] attribute as a temporary migration bridge.


Enums in Constant Expressions

PHP 8.2 allows enum cases to be used in constant expressions:

enum Status { case Active; case Inactive; }

class User { const DEFAULT_STATUS = Status::Active; }

This is particularly useful in Laravel when working with model defaults, configuration values, and factory states.


Fibers Performance Improvements

PHP 8.2 includes performance improvements to Fibers (introduced in PHP 8.1), making async-style code patterns more efficient. While Laravel doesn't use Fibers directly yet, tools like ReactPHP and Revolt that run alongside Laravel benefit immediately.


Running PHP 8.2 Locally With Larastack

Larastack ships with PHP 8.2 fully configured and all major extensions pre-enabled. There's no version management, no switching between PHP versions, no phpenv configuration. Start Larastack and you're on the latest stable PHP immediately.

Download free at larastack.click.


Frequently Asked Questions

Is PHP 8.2 compatible with Laravel 11? Yes. Laravel 11 requires PHP 8.2 as a minimum. Larastack ships with exactly what Laravel 11 and 12 need.

Do I need to update my existing code for PHP 8.2? You should audit for dynamic property usage, which is now deprecated. The rest of the changes are additive and won't break existing code.

Does Larastack support switching PHP versions? Larastack currently ships with PHP 8.2 as its default and optimized runtime.

Share

Larastack Support

Typically replies within a few hours

👋 Hi! Welcome to Larastack support. How can we help you today?