
Doppar Introduces Frozen Services, Missing in Laravel, Symfony?
We just shipped something we have not seen in any PHP framework before. Starting today, Doppar services can be marked #[Immutable] . When they are, the framework configures them freely during application boot — from your config files, environment variables, databases, whatever you need — and then permanently freezes them before the first request is handled. After that point, any attempt to mutate a property on that service throws an exception immediately, no matter where in the application the mutation is attempted. We call this Frozen Services . The Bug Every PHP Developer Has Shipped Here is a scenario you have probably encountered, or will encounter. You register a PaymentService as a singleton. It stores the payment gateway, the tax rate, whether you are in live mode. Standard setup. The service is shared across the request lifecycle — that is the point of singletons. Three months later, a junior developer writes a middleware. They need to temporarily switch the gateway for a speci
Continue reading on Dev.to
Opens in a new tab

