Symfony 5.4/6.0 is supporting them since day one
Photo by Fakurian Design on UnsplashI’ve been involved in the addition of enumerations support in the Symfony framework. Why? Because I’m mad at love with this new feature. I waited them for years in PHP. And I also love to contribute to the framework, so why not blend these two pleasures?
A news has been posted on Symfony blog about enumerations in the framework. You may read it before this article! This article is just a little supplement with additional code snippets and information.
If you never heard of PHP enumerations, here is a code snippet to show them in action:
PHP enumeration in actionPretty nit. You’re able to define typed values without having to bother to their real value. Those are called Unit Enums. You’re also able to define a value for each enum case. By doing this, they’re called Backed Enums.
You’re able to use this in Symfony with ease. Without wondering if it will work “because the feature is so new”. Let’s see this together!
Forms
Alexander M. Turek (known as @derrabus on Twitter, Symfony Core Team member)…