PHP 8.1 brings Enums, one of the most requested features in PHP.
Enums, or Enumerations, allow creating strict and type-safe structures for fixed values. An Enum structure can hold a number of values that can also be backed with integer or string values.
In this comprehensive session, we will discover what Enums are, why they are useful, how to apply them on our applications, and things to watch out for when using Enums.
This session is for those who are familiar with modern PHP practices such as Object Oriented Programming, and principles such as Liskov Substitution principle. A quick introduction will be given to catch up to speed, but familiarity with such concepts can help a lot.
What you will learn
- What are Enums.
- Why Enums are useful.
- How to use Enums
- Migrating from magic constants/values to Enums.
- Backed Enums and storing/fetching Enum values with a database.
- Backwards Compatibility
Ayesh Karunaratne is the author of PHP.Watch (https://php.watch), where he provides in-depth articles and documents on PHP and latest changes to the language.
- PHP 8.0: https://php.watch/versions/8.0
- PHP 8.1: https://php.watch/versions/8.1
- Enums: https://php.watch/versions/8.1/enums