Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Freek van Der Herten:
When empty is not empty
May 21, 2018 @ 09:38:08

As PHP developers, dealing with the "helpful" automatic type shifting the language performs can sometimes be challenging. It can lead to some interesting situations like the one Freek van Der Herten has posted about where something that seems "empty" actually isn't.

Recently when I was working on a project I got some strange results when using the empty function. That's really odd [that the result was a string and "empty" when a value was set]. How can a variable hold a string and be empty at the same time?

He includes a few other tests on the same object and firstName property using other "empty" checks with isset and is_null. Those behaved as expected so he started to look more into the class the object is based on. In the class values/properties are returned via magic methods, not direct functions. In the case of empty, this fetching isn't interpreted prior to the check and the result appears "empty". To fix the issue, he recommends implementing an __isset magic method that will then get called to ensure the value is actually set before fetching it.

tagged: language isset empty property tutorial

Link: https://murze.be/when-empty-is-not-empty

Exakat Blog:
Weird operators in PHP
May 18, 2018 @ 09:56:29

On the Exakat blog there's a new post sharing some of the weird operators in PHP that you may have not known existed. These are ones outside of the normal = or . that can really do some odd things.

If you read the PHP documentation, you will learn about a ton of operators. If you haven’t learnt about PHP operators, go do that first, we’ll wait for you.

Operators are usually made up with strange symbols, like !, -, =>, <=>, ^ or ~. Really, some are plain readable like and, while some are merely an missed attempt at being readable, and actually hide a double personnality, like xor.

You probably think you know PHP’s documentation in and out, but there is always more to learn. So I dove deep into the core of PHP code, and looked some special PHP operators that are lesser known, but very useful in your daily coding.

There's ten of the odd operators on their list including:

  • the "b" operator for strings
  • the "left object" operator
  • constant names with * and %

Check out the full post for the details (and code examples) on each of these and more.

tagged: weird operator list language example

Link: https://www.exakat.io/weird-operators-in-php/

Joe Ferguson:
Getting Lucky With Crystal in Homestead
May 16, 2018 @ 09:12:27

Laravel users are no doubt familiar with the Homestead VM project that makes it quick and easy to get new sites up and running. In this new post to his site, project maintainer Joe Ferguson covers some changes made to run something besides a PHP framework: a Crystal project.

A few days ago a random internet stranger (Rid) showed up in the Larachat Slack #homestead-dev room. This is about the best real time chat support for Homestead. Rid proceeds to ask about building something like Homestead for the framework he was working on called Lucky for the [Crystal programming language](https://crystal-lang.org/). After we chatted about Vagrant and Docker I mentioned that it wouldn’t be too difficult to get supported in Homestead. Rid shared some helpful URLs and I was off to the races.

Joe mentions that the next Homestead box will come configured to support this out of the box but also provides instructions if you'd like to set it up before that. The Cyrstal language is inspired by Ruby and is designed to be as "fast as C".

tagged: crystal laravel homestead language framework lucky tutorial

Link: https://www.joeferguson.me/getting-lucky-with-crystal-in-homestead/

Jordi Boggiano:
PHP Versions Stats - 2018.1 Edition
May 15, 2018 @ 12:53:09

Jordi Boggiano, lead developer on the Composer project, has posted another of his PHP version statistics posts, this time for the first part of 2018.

It's stats o'clock! See 2014, 2015, 2016.1, 2016.2, 2017.2 for previous similar posts.

A quick note on methodology, because all these stats are imperfect as they just sample some subset of the PHP user base. I look in the <a href="https://packagist.org/>packagist.org logs of the last month for Composer installs done by someone. Composer sends the PHP version it is running with in its User-Agent header, so I can use that to see which PHP versions people are using Composer with.

The remainder of the post shares some of the results and differences since November 2017. Among the highlights are:

  • The use of PHP 7.2 has increased by a large percent
  • The use of all over versions (including PHP 7.1) is dropping
  • There is still a large number of packages that only require a version in the PHP 5.x range to be installed

Check out the full post for the complete stats on versions in use and trends (along with some nice graphs of the results).

tagged: composer statistics 2018 version language install require

Link: https://seld.be/notes/php-versions-stats-2018-1-edition

Frank de Jonge:
Array destructuring in PHP
May 01, 2018 @ 09:48:15

Frank de Jonge has a post to his site sharing some helpful hints around the use of arrays in PHP. In this quick post he covers some of the array "superpowers", list assignments and nested destructuring.

One of the things I like the most about JavaScript, and PHP also to some extent, is how flexible and expressive they CAN be (but not always are). I also believe that JavaScript, PHP, and Python have a number of features that make them a good fit for serving the forefront of the web.

[...] The most versatile type of PHP, to me, is the array. The array can be used to act like many different classic data types. You can use them as a List, a Set (although that requires some specific handling), a HashMap, just to name a few.

He starts with the "superpowers" that arrays gained in PHP 7.1 (the square bracket syntax for destructuring) and some code examples showing it in action. He then moves on to show how this update works for list assignment. He finishes up the list with a look at nested destructuring and referencing values from subarrays with this same square bracket syntax.

tagged: array destructure language square bracket php71 tutorial

Link: https://blog.frankdejonge.nl/array-destructuring-in-php/

PHP.net:
PHP 7.1.17 & 5.6.36 Released (Bugfix)
Apr 30, 2018 @ 11:03:24

On the main PHP.net site they've announced the release of the next versions in the PHP 5.6 and 7.1 series:

Both are bugfixes for their respective versions and are bugfix releases with several issues corrected in the Exif, LDAP, Phar and iconv handling. It is recommended that you upgrade to either of these releases to correct these issues.

As always, you can download these latest releases either from a mirror on the main downloads page or windows.php.net for the Windows executables.

tagged: language release bugfix php56 php71

Link: http://php.net/index.php#id2018-04-26-3

Stitcher.io Blog:
What PHP can be
Apr 18, 2018 @ 10:23:39

The Stitcher.io blog has a new post from author Brentd sharing some thoughts about what PHP could be if "that one feature" were added. For him it would be a true strong typing system that didn't require workarounds to make happen.

Have you ever wondered how your life as a PHP developer would be different if that one feature you want was added? I've made the thought experiment quite a few times already, and came to surprising conclusions.

Let's take, for example, the debate about strong types in PHP. A lot of people, including myself, would like a better type system. Strong types in PHP would definitely have an impact on my daily work. Not just strong types, I also want generics, better variance and variable types. Improvements to PHP's type system in general would have quite the impact on my programming life.

So what's stopping us from reaching a solution?

He covers a few different topics in his discussion of the feature including issues around common vocabulary and the use of the feature (in this case type enforcement). He finishes the post talking about the impact a feature like this could have on PHP and some of the benefits that could come with a strongly typed version of the language.

tagged: opinion language feature type strict

Link: https://www.stitcher.io/blog/what-php-can-be

ZFort Blog:
PHP Digest #15 (March 1st - 25th, 2018)
Apr 11, 2018 @ 11:52:35

The ZFort Group blog has posted their latest PHP Digest for March 1st - 25th, 2018: Digest #15.

A tool for quick smoke testing, a PHP parser in PHP, a cool extension for PhpStorm, an object graph visualizer, a library for implementing Event Sourcing in PHP apps, the lightweight in-memory message queue, and more. This digest seems to be really informative. Keep on reading!

Included in this list are topics like:

  • News about the PHP language and releases
  • PHP internals changes (moving towards PHP 7.3)
  • Links to various interesting and useful tools
  • Links to other tutorials, articles and updates from various projects.

The projects in that last item include Laravel, Zend Framework, Drupal and Symfony. Check out the full post for the full content.

tagged: phpdigest ep15 march2018 community language news update

Link: https://www.zfort.com/blog/php-digest-march-2018/

Leonid Mamchenkov:
Awesome list of Important Podcasts for software engineers
Apr 05, 2018 @ 09:51:28

Leonid Mamchenkov has a post on his site that points out a great resource for all of the podcast fans out there, the Awesome podcasts list.

Awesome podcasts is a curated list of podcasts for software engineers. The list includes a whole lot of sections – one for each programming language out there, generic software engineering, tools, etc.

The list is broken down into sections for various programming languages and technologies such as C++, Git, Python, PHP, Java and Rust. There's also sections for different topics not covered by specific technology such as security, general web development and community/inspirational topics. The list is a GitHub repository so if you have a favorite podcast that's not already on the list, be sure to send in a pull request to get it added.

tagged: awesome podcast list engineer language technology topics

Link: http://mamchenkov.net/wordpress/2018/04/05/awesome-list-of-important-podcasts-for-software-engineers

PHP.net:
PHP 7.1.16 & 5.6.35 Released
Mar 30, 2018 @ 09:15:55

On the main PHP.net site, they've posted announcements about the release of minor versions of PHP 7.1.x and 5.6.x: 7.1.16 and 5.6.35.

The PHP development team announces the immediate availability of PHP 5.6.35 [and PHP 7.1.16]. This is a security release. One security bug was fixed in this release. All PHP 5.6 [and 7.1] users are encouraged to upgrade to this version.

The bugfixes included in these releases deal with changes in the FPM handling, ODBC functionality, and Phar building. You can download this latest release from the main downloads page (source) or from the windows.php.net site for the Windows binaries.

tagged: language release php7 php56 bugfix security

Link: http://php.net/index.php#id2018-03-29-3