Latest PEAR Releases:
On the PHP.net site they've made an announcement about releases of all currently supported major PHP versions with bugfix/security releases.
The PHP development team announces the immediate availability of PHP [7.0.33, 7.1.25, and 7.2.13]. Five security-related issues were fixed in this release. All PHP 7.0 users are encouraged to upgrade to this version.
There's also a note for the PHP 7.0.33 release based on the release and support timelines: this will be the final release, of any kind, for the PHP 7.0.x branch including security support. If you haven't already upgraded past version 7.0.x, there's never been a better time!
Matthew Weier O'Phinney has posted a tutorial to his site sharing a method he's found for creating Exception types dynamically allowing you to create a system that can still be caught by normal means but is more flexible than hard-coded exceptions.
We pioneered a pattern for exception handling for Zend Framework back as we initially began development on version 2 around seven years ago. The pattern looks like this: we would create a marker ExceptionInterface for each package. [Then] we would extend SPL exceptions and implement the package marker interface when doing so.
What this gave users was the ability to catch in three ways. [...] This kind of granularity is really nice to work with. [...] So, what happens when you're writing a one-off implementation of something that is expected to throw an exception matching one of these interfaces?
Why, use an anonymous class, of course!
He includes an example of putting this approach to work, using a
throw call along with a dynamic (anonymous) class to extend the required class and implement the associated interface. In his example he creates a dynamic exception for handling a "not found" type of exception.
On the TutsPlus.com site they've posted a tutorial for those new to PHP and MySQL out there sharing the basics of CRUD operations using the built-in language functionality ("CRUD" stands for "Create, Read, Update, Delete").
In this article, we're going to explore how you could use a MySQL database to perform CRUD (create, read, update, and delete) operations with PHP. If you want to get your hands dirty with database connectivity in PHP, this article is a great starting point.
If you are just getting started with PHP, you probably realize that database connectivity is an essential feature that you'll need to get familiar with sooner or later. In most cases, a database is the backbone of any web application and holds the data of the application. So, as a PHP developer, you'll need to know how to deal with database operations.
In this article, we'll keep things simple and explore how to use the core mysqli functions. In upcoming articles of this series, we'll explore a couple of other ways to handle database connectivity.
They then walk you through some of the basics of:
Each item on the list comes with plenty of explanation and example code to get you on the right path to learn these basic concepts.
On the main PHP.net site they've announced the first stable release in the PHP 7.3.x series: PHP 7.3.0!
The PHP development team announces the immediate availability of PHP 7.3.0. This release marks the third feature update to the PHP 7 series.
PHP 7.3.0 comes with numerous improvements and new features such as:
- Flexible Heredoc and Nowdoc Syntax
- PCRE2 Migration
- Multiple MBString Improvements
- LDAP Controls Support
- Improved FPM Logging
- Windows File Deletion Improvements
- Several Deprecations
You can find out more information about these features and view the Changelog for this release from the announcement. As always, you can download this latest release from either the main downloads page or windows.php.net for the Windows binaries. If you need more information on moving to this new release, check out the migration guide.
Popular posts from PHPDeveloper.org for the past week:
Here's what was popular in the PHP community one year ago today:
Freek Van der Herten has a tutorial posted to his site sharing some customizations you can make to PHP code generation in PhpStorm to fix some issues he's noticed in his own development work in the IDE.
I've been using PhpStorm for quite some time now, but never took the effort to fix a few minor annoyances I had with it.
He shows how to change the generation for:
The final item in the post isn't so much a code generation change as it is a tip for saving these changes and your other configuration options. He shows how to back them up on a git repository out on GitHub.
In a recent post to his site Jonathan Reinink has written up a guide to using dynamic (Eloquent) relationships in Laravel applications by making use of subquery functionality. In it, he shows how to make use of the
selectSub method to select additional information in a single query versus having the overhead of custom, hard-coded relationships.
When building web apps that interact with a database, I always have two goals in mind: keep database queries to a minimum [and] keep memory usage to a minimum. These goals can have a drastic impact on the performance of your app.
Developers are typically pretty good at the first goal. We're aware of N+1 style problems, and use techniques like eager-loading to limit database queries. However, we're not always the best at the second goalkeeping memory usage down. In fact, we sometimes do more harm than good trying to reduce database queries at the expense of memory usage.
He starts off with the challenge he's trying to solve: gathering login information for users in a performant way. He includes the schema for the users and logins table and shows the code of how a normal relationship select might look to get login information for each user (creating an N+1 issue).
To help solve the issue, they try caching the last login information but realize they can do better - this is where subqueries come in. They provide an example of using the
selectSub method to get the login information, mapping it to a macro for easier use and defining scopes. Finally, the tutorial shows how to use this method to select information via dynamic relationships. It also talks about lazy-loading issues and if the same thing could be accomplished with a "has one" relationship.
On the Delicious Brains site, there's a tutorial posted asking WordPress plugin developers if their code is ready to work with Gutenberg, the next major release of the editor used in the popular blogging tool and content management system.
WordPress 5.0 is right around the corner with the flagship feature, the new Gutenberg editor, set to change the WordPress landscape dramatically. Gutenberg not only impacts how you write content in WordPress, but how developers build plugins for WordPress.
[...] In this post I’ll walk you through the process I took for making Intagrate, my Instagram WordPress plugin, Gutenberg-compatible, which will hopefully get you started on making your own plugins Gutenberg-ready.
The post starts with some general things to consider about Gutenberg's functionality as compared to the classic editor and some key places to check in your own plugins. They then provide a guide to testing your plugin by installing the standalone editor package. It then walks through the three main places to check functionality:
The post ends with some suggestions of possible enhancements such as making use of shortcodes and converting custom meta boxes.