Posts tagged with enum

Best Practices for Using PHP Enumerations

jeffochoa.me - submitted by Jeff

Although PHP Enumerations are meant to provide an easy and elegant solution to work with a predefined set of values, these classes are often misused, resulting in a lack of consistency due to the introduction of all sorts of methods that increase their complexity. In this article, we are going to go through some practices (both good and bad) with the goal of clarifying the understanding of these types of objects to help you build a more resilient and consistent codebase.

Read more [jeffochoa.me]

Join 9,500+ smart developers

Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

A package to handle enums

stitcher.io

Recently we released a new package called enum. In a new post on his blog Brent tells you what the benefit of working with enums is and how our package differs from the alternatives.

Today I want to explore some of the difficulties we encounter when solving problems like enums in userland. I'll talk about my personal take on enums, and we'll ponder on core support.

Read more [stitcher.io]