OpenLampTech No. 133
Enhancing Drupal 11 | Lesser-known PHP tricks | WooCommerce HPOS extension recipe(s) | SQL ENUM vs Check Constraint vs Lookup table
Thank you for reading the OpenLampTech newsletter!
If someone awesome shared this newsletter with you and you are not yet subscribed, please use the Subscribe button below and join:
OpenLampTech has sponsorship opportunities for your brand, product, or service in the weekly newsletter. As an independent publication, collaboration is very affordable.
All commentary and opinions are mine unless otherwise quoted.
Lesser-Known Tips and Tricks of php
PHP as a language continues to evolve. I am likely only using a fraction of its functionality and capabilities.
Many of the tips and tricks in this article I am/were aware of. The null coalescing operator (??) is an alternate shorthand to the similar ternary operator (?:).
But others such as the spread operator (...), I've yet to use in any of my projects.
Learn more about these and other recent PHP tips and tricks.
[Medium]
A change in PHP 8 that affects Laravel tests and transactions
Joel Clermont of Mastering Laravel has a great tip on how newer PHP versions handle database transaction errors.
As noted, in MySQL (and according to my understanding, other SQL implementations too), Data Definition Language (DDL) commands (ALTER, CREATE, DROP, and others…) will automatically commit any current TRANSACTION.
The lesson for me here is that after studying the official MySQL documentation, I learned that although TRUNCATE does remove all the rows from a table like DELETE, TRUNCATE does not cause ON DELETE database triggers to fire like DELETE does.
[Mastering Laravel]
The Ability to Prevent Destructive Commands From Running is Coming to Laravel 11
While I'm not a Laravel developer, this mighty framework provides a lot of features right out of the box.
This article is a high-level overview on an upcoming trait that prohibits specific destructive commands from running in a production-level application.
Anything geared toward better database management is always a plus in my opinion. Without a quality well-maintained database, an application cannot thrive or succeed.
[Laravel News]
Enhancing Drupal 11: Transitioning Deprecated Modules to Contributed Alternatives
This article covers how Drupal 11 innovates as a Digital Experience Platform (DXP) and removes certain (older) modules.
Similar contributed modules will replace these module's functionality according to the article's content. This will allow for more focused development by the Drupal core maintainers. Also, community modules allow for more rapid releases and updates as well as ownership (in their direction).
[The Drop Times]
ENUM vs Check Constraint vs Lookup Table: Which Is Better?
Ben Brumm has some of the best SQL-related content in my opinion and he was the first developer interviewed here in OpenLampTech.
ENUMs, Check Constraints, and Lookup tables (using a FOREIGN KEY) all serve a (somewhat) similar purpose - to validate incoming data for a column.
Many SQL implementations do not support the ENUM data type but MySQL and PostgreSQL do.
See examples in MySQL and learn about some considerations on which may be a better option for data validation needs.
[Database Star (YouTube)]
High-Performance Order Storage or HPOS is the new(er) way that WooCommerce stores and handles commerce order data in the MySQL database.
I'm not sure if at the time of writing if HPOS is fully ported over to all WooCommerce installations - old and new (it is the default for new WooCommerce stores). However, I'm sure someday it will not be optional. Either way here is a handy resource for extending HPOS in WooCommerce.
[Woo Developer Docs]
[#Affiliates and Classifieds] - Your support keeps the OpenLampTech newsletter free for readers
Take your Laravel applications to the next level with Battle Ready Laravel by Ash Allen. (affiliate)
Ultimate Laravel Boilerplate to help other indie hackers deliver their SaaS in hours. Get started with LaraFast today! (affiliate)
Popups, newsletters, and abandoned carts. Use Omnisend with integrated email and SMS campaigns. (affiliate)
Thank you for reading. I hope you have a great rest of your week.
Take care.
Josh Otwell
OpenLampTech is a reader-supported publication. You can support the publication with a virtual coffee for as little as $3 (USD).
Some links may be affiliate links from which I earn a small commission at no additional cost to you.


