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

Exakat Blog:
PHP assertions and their usage
Jan 18, 2018 @ 11:16:58

On the Exakat blog there's a post that covers assertions in PHP, a built-in tool the language provides to help perform simple value based evaluation against certain criteria.

PHP has a clever native debugging tool : the PHP assertions. In a nutshell, assertions are a function call to assert(), that triggers an error when a condition is not satisfied.

[...] Unlike debugging conditions, the assert() syntax has to be read in a positive way. When the condition, aka as the first argument, is satisfied, all is fine, and process goes on; when the condition is not satisfied, then an error is triggered: the message of the error is the second argument.

The post then gets into more detail about the assertions, noting that the result has to be positive and that they can be somewhat configured (basically turned on/off and the error level can be adjusted). It also covers some examples of things to test with assertions, how they should be treated as debugging and to avoid using them on resources outside the code (like database connections).

tagged: assertion usage language native tutorial introduction

Link: https://www.exakat.io/php-assertions-usage/

Brandon Savage:
What version of PHP should my package support?
Jan 10, 2018 @ 10:09:46

In a post to his site Brandon Savage shares some of his thoughts about PHP package development and suggests how to figure out what versions of the PHP language it should support.

Everybody likes “the new hotness.” [...] Perhaps, then, it shouldn’t be so surprising that people get tremendously excited when a new version of PHP comes out. People look forward to the new features, whether they be the trailing commas in list() syntax or counting of non-countable objects.

[...] A new version of PHP can pose challenges to open source package maintainers. There are questions, like what is the minimum version we will support and how soon can we take advantage of the new features we’ve been waiting on? I want to offer up some thoughts, both as a package maintainer and a user of many open source packages.

He goes on to suggest that package authors should support down to the last currently supported version of the language (v5.6 at the time of this post). This allows users of the package that may be restricted and don't have the "new hotness" to keep using the package. He points out that this doesn't mean that you shouldn't use new features, just that older versions should be supported along with the newer ones for those depending on the package. He makes three suggestions as to how he thinks package maintainers should approach the issue:

  • maintainers should feel comfortable in bumping up the requirement to the latest (in a major release)
  • maintainers should also ensure that the support is still there for older versions that can't use the newer features
  • maintainers should bump up this minimum version when it falls out of active support
Supporting old versions of a language isn’t fun and isn’t glamorous. But it’s important. It’s important because there’a segment of the population who can’t upgrade yet. It’s important to make components accessible to a larger, broader audience who is struggling to find best practices and use modern packages. And it’s important for those users who are tied to a legacy version, and are struggling to get upgraded. But it’s the right thing to do for the community.
tagged: package version language support opinion maintainer old new

Link: https://www.brandonsavage.net/version-php-package-support/

PHP.net:
Multiple Versions Released - 5.6.33, 7.1.13, 7.2.1 and 7.0.27
Jan 05, 2018 @ 10:16:17

On the [main PHP.net site]http://php.net/() today they've announced the release of new released of all currently supported versions of the language:

All of these releases contain similar bugfixes correcting security issues reported in the language including problems in the CLI server, Phar handling, Zip functionality and the Opcache feature. It is suggested to update to these latest versions as soon as possible to prevent issues with these bugs.

As always you can download the source versions of these latest releases from the main downloads page or the Windows binaries from windows.php.net. If you're interested in the changes made, check out the Changelogs for PHP 7 and PHP 5.6.

tagged: version release language php56 php71 php72 security bugfix

Link: http://php.net/downloads

Jeff Madsen:
Using Laravel Translation Strings in Vue.js
Dec 28, 2017 @ 09:51:02

Jeff Madsen has a new post to his site showing you how integrate Laravel's translations strings with a Vue.js frontend making it simpler to maintain only one source for the translation of content in your application.

One issue you will face if you need to make a multi-lingual site is how to keep your translations organized for both your back-end framework and your javascript components. I’m going to demonstrate the basic technique for this, using Laravel and Vue.js for my example.

While his examples make use of Laravel and Vue.js, the approach is agnostic of most tools and could be modified to integrate with other technologies pretty easily. He builds a system where the translations are kept in PHP files which are converted into something Vue can read and use. He starts with the backend, showing how to use Laravel's localization functionality to set up the files and shift between languages. He then makes use of the lang.js library to pull the contents of these files into Vue and adds in a bit of code to push those values into components.

tagged: vuejs language translation tutorial string laravel

Link: https://medium.com/@codebyjeff/using-laravel-translation-strings-in-vue-js-e2e35b7aafca

Marcel Pociot:
2017 - A PHP Year in Review
Dec 26, 2017 @ 09:39:40

Marcel Pociot has written up a post to finish out 2017 and provide a year in review for the community and language via some Github statistics.

It's this time of the year again - the end of the year is coming up fast, so why not step back and take a look at what we, as a PHP community, have achieved this year?

For these statistics, I used the free GitHub Archive data in combination with Google BigQuery, which lets you process 1TB of data per month free of charge.

So let's take a look at some numbers

He first breaks it up into three main categories:

  • most starred PHP repositories
  • most starred new PHP repositories
  • most contributed PHP repositories

From there he "digs deeper" and looks at the packages requiring the most dependencies and graphs the frameworks according to how many dependencies they require to install.

tagged: yearinreview language github repositories starred dependency

Link: http://marcelpociot.de/blog/2017-12-21-a-php-year-in-review

Pehapkari.cz:
Domain-Driven Design - Model
Dec 18, 2017 @ 09:03:21

On the Pehapkari.cz blog they've continued their "Domain-Driven Design" series with the latest post focusing on models.

All of us model every day. A friend tells us a joke, we imagine the situation and if we model it as is intended, we find the situation funny. A customer wants to have a new functionality and while he speaks, we try to imagine what does the customer wants - we model.

We are going to take a look at what is software modeling, how can we express the model and how can we capture key concepts.

The post starts off with an overview of what "modeling" is to get everyone on the same page. It also talks about validation of the model by domain experts and some questions to ask to ensure the model provides the right data. They include a more practical example of a shopping cart and some key concepts and constraints that might come along with it. Some illustrations are included in the post to help give a bit more visual context to the contents.

tagged: domaindrivendesign domain language model series part2

Link: https://pehapkari.cz/blog/2017/12/16/domain-driven-design-model/

24 Days in December:
Giving back to PHP
Dec 12, 2017 @ 10:29:43

On the "24 Days in December" advent calendar there's an article posted from Kalle Sommer Nielsen that talks about some ways that you can give back to PHP including documentation updates, contributing to the core code and just helping out the community in general.

PHP has a tremendous community behind it, that community consists of you and me, and millions of others that help promote PHP by continuing to develop awesome applications that power some of the biggest websites in the world, but within this community exists a relatively small community that actively develops PHP, such as making it run on your favorite platform or making your favorite extensions compile and work or even keeps the documentation up-to-date. Today I want to dwell into that community, and perhaps giving you flavor enough to contribute back to PHP with code.

The article suggests several places you can give back including:

  • updating and adding changes to the PHP manual documentation
  • participating in the various project mailing lists
  • reviewing pull requests on the project's GitHub repository
  • writing tests for the untested parts of the language

Kalle wraps up the article talking about his own experience with the language over the years and how it ended up that he was the one to remove register_globals from the language one day.

tagged: give back contribute language opinion 24daysindecember

Link: https://24daysindecember.net/2017/12/11/giving-back-to-php/

Pehapkari.cz:
Domain-Driven Design - Language
Dec 08, 2017 @ 09:46:34

On the Pehapkari.cz blog today they've posted an article about something that, while not directly related to the code of your application, can help to improve the end result: defining a common language for domain-driven design.

Domain-driven design is a software design that focuses on understanding underlying business. It is useful for long-term projects because it leads to high-quality software that serves users. It helps when dealing with difficult problems, keeps track of core problems and prevents us from getting lost in the code.

The author starts the article by talking about issues before adopting a domain-driven design process and briefly describes what DDD is and what its goals are. The post then gets into some the basics behind defining your own domain and gives an example of definition of "account" and "price" for an e-commerce application. It then goes on to talk about goal of creating a ubiquitous language for the product that also includes functionality and process, not just the objects in the system.

tagged: domaindrivendesign domain language ubiquitous introduction

Link: https://pehapkari.cz/blog/2017/12/05/domain-driven-design-language/

PHP.net:
PHP 7.2.0 Released
Nov 30, 2017 @ 11:20:32

The PHP development group has a post on the main PHP.net site officially announcing the availability of the latest major version in the PHP 7.x series: PHP 7.2.0.

The PHP development team announces the immediate availability of PHP 7.2.0. This release marks the second feature update to the PHP 7 series.

There's a number of new features and changes that come with this release including counting of non-countable objects, the Object typehint, the removal of mcrypt and the new libsodium extension. You can view the full list of changes and bug fixes in the Changelog.

Downloads are available in the usual places: the main downloads page for the source packages and windows.php.net for the Windows binaries. Additionally a migration guide has been posted to help with migrating to this new version.

tagged: php72 release language version update migration

Link: http://php.net/archive/2017.php#id2017-11-30-1

PHP.net:
PHP 7.1.12 Released
Nov 28, 2017 @ 11:16:22

On the main PHP.net site they've posted an announcement about the latest release in the PHP 7.1.x series: PHP 7.1.12:

The PHP development team announces the immediate availability of PHP 7.1.12. This is a bugfix release, with several bug fixes included. All PHP 7.1 users are encouraged to upgrade to this version.

Bugs in this released include issues in PHP's CLI handling, GD image manipulation, internationalization and reflection with Mysqli. You can find the full listing of issues fixed in the full Changelog. As always you can download this latest release from the main downloads page for the source packages and windows.php.net for the Windows binaries.

tagged: language release php71 bugfix upgrade

Link: http://php.net/index.php#id2017-11-24-1