Backed Enums Are Your Status Fields' Best Friend
Order statuses as loose strings invite typos, scattered labels and unguarded transitions. PHP 8.1 enums centralize the values, their behavior, and - with match - force you to handle every case.
Software Engineer
I build web applications and share what I learn along the way.
Step-by-step programming tutorials on PHP, JavaScript, Laravel, WordPress and more.
Order statuses as loose strings invite typos, scattered labels and unguarded transitions. PHP 8.1 enums centralize the values, their behavior, and - with match - force you to handle every case.
?->, ??=, throw as an expression, and the spaceship - four small operators from recent PHP that collectively delete the noisiest guard code in legacy files.
PHP 8.1 turned functions into values you can pass, store and compose - ending the string-callable era of 'array_map("strtoupper", ...)' and its silent refactoring bugs.
Titles, prices and buttons at different heights across cards - the misalignment that made designers invent equal-height hacks - is what subgrid was built to end.
Order confirmations, tickets, recipes, documentation - they get printed and PDF-saved daily. Twenty lines of @media print separates professional from embarrassing.
Notification badges showing "0", alert boxes rendering as empty bordered rectangles, list wrappers with padding and no list - :empty cleans up after your templates.
The material-style label that sits in the field and floats up when you type is a pure CSS pattern - one pseudo-class, one sibling selector, one transition.
Scroll to the bottom of a dropdown or chat panel and the page behind starts moving - scroll chaining. One property contains it, no JavaScript scroll-locking required.
The soft fade at the bottom of a collapsed article, scroll hints on overflowing tabs, icon recoloring from a single SVG - all one property that composites with gradients.
Slanted section dividers, circular image crops, magazine-style text wrap around a portrait - two properties cover the layout tricks everyone assumes need images.
A fixed header readable over every hero image, duotone photos without Photoshop, highlight effects that multiply like a real marker - blend modes, and the isolation property that keeps them caged.
Darker-on-hover, tinted backgrounds, borders derived from the brand color - color-mix computes them in the browser from one source color, and your theme stops needing a palette generator.