OpenLampTech No. 138
JSON Schema in PHP | Parameter binding - Doctrine ORM | Embracing AI | MySQL 8 IN() queries performance | WooCommerce lookup table optimization | MySQL Auto-Increment problems.
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:
Doctrine ORM Docs - Query Parameter Binding
Perhaps the most important reason to bind query parameters in PHP application code is to thwart SQL Injections (or at least mitigate them).
While researching content for (more) content ideas here in OpenLampTech, I happened upon the Doctrine Query Builder documentation and read up on how Doctrine Query Builder handles parameter binding.
I've not used Doctrine in any production projects but the potential (and interest) is there.
Similar to many ORMs, Doctrine allows for either numeric or string-based placeholders, each with a different syntax.
Validating JSON with JSON Schema and PHP
PHP v8.3 includes JSON (syntax) validation with the json_validate()
function.
As covered in this article, there are many reasons why JSON validation is crucial. Specifically, since it is a widespread data exchange format.
JSON Schema is an additional means to implement a more fine-tuned and hardened (perhaps a bad word choice here) validation.
JSON is everywhere and it seems like there is more of a chance your application will be working with it (at some point) than not.
[dev.to]
Symfony UX 's Icons polish your projects to a Professional and Authoritative sheen
Reuben Walker of Symfony Station shares the goods on Symfony UX Icons.
Not only do Symfony UX Icons have many to already choose from, but you can include them from your templates as well.
And, Symfony UX Icons work with Twig, one of the more favorable PHP templating languages.
[Mobile Atom Code]
[Affiliate]
Consuming APIs in Laravel - Learn how to confidently integrate third-party APIs in your Laravel projects using maintainable, testable, and extensible code.
Embracing the AI Revolution: A Drupal Developer's Perspective
I've personally had such a mixed bag with AI.
Until recently…
I don't think AI is going to replace anyone who has any amount of sense. Let's face it, AI can still spit out a lot of garbage.
However, it can be used with intelligence. And speed up some tasks.
I do think developers who use AI effectively - as more of an assistant as opposed to something intelligent enough to just do the work without any monitoring - are on a solid track.
[The Drop Times]
OpenLampTech has sponsorship opportunities for your brand, product, or service in the weekly newsletter. As an independent publication, collaboration is very affordable.
Is PHP Really Dying? My Approach and Experiences
Nope.
PHP is nowhere near dying…
Take a look around. Chances are you will land on a WordPress website. Guess what? WordPress is (mostly) built with PHP.
If that isn't enough, how about the biggest elephant in the room, Laravel?
Laravel is one of (if not the most) thriving PHP frameworks with one of the largest and most passionate communities surrounding it.
[Medium]
WordPress Database Class (wpdb) Documentation: SQL-escaped data
Sharing some bits of information here on how to protect queries against SQL Injection attacks in WordPress.
It is best to use the prepare()
method and escape all data.
Available Placeholders are:
For a string -
%s
For an integer -
%d
For a float -
%f
Another good resource is the page on validating data.
[WordPress Developer Resources]
Why Are Queries with Many IN Values More Expensive After Upgrading to MySQL 8.x?
It seems like I am/was aware that in certain queries, the IN()
operator can be less performant. I wish I could find the source (of truth) for that.
However, this article has some interesting comparisons for IN()
queries between MySQL v5.7 and v8.x. Especially since MySQL v5.7 is EoL.
Turns out, there is a bit of a performance regression between MySQL v5.7 and v8.x for identical IN()
operator queries.
[Percona]
Practical Problems with Auto-Increment
This is a bit of a dated article from over a year (plus) ago, which is a lifetime in software with as rapid a pace as it keeps.
In certain circumstances, MySQL v5.7 could (re)use the same Auto-Increment value between server restarts.
Something I was unaware of.
This could cause some very annoying bugs.
MySQL v8.x mitigates this problem with different internal Auto-Increment storage practices. So does PostgreSQL.
MySQL v5.7 is EoL at this time so this shouldn't be an issue for newer MySQL versions.
An optimization for the product attributes lookup table is coming
This (upcoming) update will address update and regeneration performance issues for products with large numbers of variations.
At this time, the product attributes lookup table remains unchanged and this optimization is optional.
I think this is going to be a useful enhancement for specific stores because, at the end of the day, optimized database queries are hard to beat.
As mentioned in this article, some extensions may be incompatible due to missed hooked executions since these optimizations are a direct result of database queries instead of WordPress/WooCommerce functions.
[Woo Developer Blog]
[#Affiliates and Classifieds] - Your support keeps the OpenLampTech newsletter free for readers
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)
Should OpenLampTech cover more than MySQL, PHP, and the LAMP stack?
I have a very technical day job in which I use a plethora of other skills and technologies alongside (My)SQL and PHP.
I am not the foremost expert in any of them but, I do use them regularly (mostly daily) and am thinking of sharing some small bite-sized tips on them.
This would be either a separate section in OpenLampTech or altogether another newsletter (depending on how it is received).
Some of the tips I am considering sharing are about:
Python and PowerShell scripting
Excel and Google Sheets tips
Microsoft Access Database programming/scripting
General computing and keyboard shortcuts for efficiency
Thank you for reading. I hope you have a great rest of your week.
Take care.
Josh Otwell
Some links may be affiliate links from which I earn a small commission at no additional cost to you.