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

Zend Developer Zone:
Deprecations in PHP 7.2
Jun 28, 2017 @ 11:20:50

On the Zend Developer Zone there's a new post sharing some of the deprecations coming with PHP 7.2, the next release in the 7.x series (planned release sometime later this year).

PHP is a living language and as such, as some things are added, others are removed. Since PHP adheres to the best practice of Semantic Versioning, nothing will be going away in PHP 7.2, but some things will be marked as “Deprecated” so that developers can start removing them from their code and finding better ways to get the job done.

PHP 7.2 brings us a new list of things that will be eventually going away. The complete list, as well as explinations and voting can be found at “PHP RFC: Deprecations for PHP 7.2

They include a "hit list" of the functionality that will be affected including the removal of support for __autoload, the create_function function, removal of assert and the (unset) cast. The RFC has been moved to the "Accepted" state so now work will be done to make these and other deprecations happen in this next great release.

tagged: language deprecation php72 list rfc

Link: https://devzone.zend.com/7628/deprecations-php-7-2/

SitePoint PHP Blog:
There’s a Gender Extension for PHP
Jun 26, 2017 @ 13:58:25

On the SitePoint PHP blog there's a new post from editor Bruno Skvorc sharing information about a "gender" extension for PHP that tries to guess the gender of a first name.

Recently, I ventured into a section of the PHP manual which lists extensions that are used to help with Human Language and Character Encoding. I had never looked at them as a whole – while dealing with gettext, for example, I always kind of landed directly on it and ignored the rest. Well, of those others, there’s one that caught my eye – especially in this day and age given the various controversies – the Gender extension.

This extension, in short, tries to guess the gender of first names. As its introduction says: "Gender PHP extension is a port of the gender.c program originally written by Joerg Michael. The main purpose is to find out the gender of firstnames. The current database contains >40000 firstnames from 54 countries."

This is interesting beyond the fact that the author is kinda called George Michael. In fact, there are many aspects of this extension that are quite baffling.

He then walks through some examples of putting the extension to use, evaluating various names in different languages and gauging the results. The extension allows for definite answers (is male/female), relative results, unisex, a "couple" or, when all else fails, erroring or giving a "not found" result. It also can check for "nicknames" for common names. He walks you through getting it installed and shows other functionality for getting similar names and checking for nicknames, showing code examples and the resulting output.

tagged: gender extension language tutorial introduction install example

Link: https://www.sitepoint.com/theres-a-gender-extension-for-php/

Marco Perone:
Maybe in PHP
Jun 22, 2017 @ 10:35:16

In a recent post to his site Marco Perone looks at the idea of "maybe" in PHP, having functionality that acts a default value if no value is present. This idea is implemented in other languages like Haskell and Elm.

Doing functional programming in a language as PHP, which is almost completely used as an imperative or object oriented way, is not always easy. Good progresses have been made thanks to the introduction of callable type hints in PHP 5.4 and the diffusion of functional interfaces like the ones present in PSR-7.

Still, all “good” PHP code is still written using objects and classes and the object oriented perspective on the world strongly influences even the most functional oriented libraries.

In this post I would like to propose as an example how we could implement the Maybe type in PHP. We will see how some open source libraries do this, we will see an alternative solution and we will raise concerns about some modelling issues.

He starts off by describing what the "maybe" functionality is and gives some examples of it in use in other languages. He points out that while there's several PHP libraries that implement this kind of default handling, it's not in the PHP core language. He works through some of these libraries and shows them in use: monad-php, Phunkie, php-maybe-monad and php-fp-maybe. He wraps up the post showing his own suggested implementation and how it could help resolve some of the issues he found with the other libraries as he worked through them.

tagged: maybe language default variable functional tutorial library

Link: http://marcosh.github.io/post/2017/06/16/maybe-in-php.html

PHP.net:
PHP 7.2.0 Alpha 2 Released
Jun 22, 2017 @ 09:12:12

The PHP.net site has announce the latest alpha release for the upcoming PHP 7.2.0 release: PHP 7.2.0 Alpha 2:

The PHP development team announces the immediate availability of PHP 7.2.0 Alpha 2. This release contains fixes and improvements relative to Alpha 1. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system.

[...] For information on new features and other changes, you can read the NEWS file, or the UPGRADING file for a complete list of upgrading notes. These files can also be found in the release archive.

As these are just development releases, the downloads for them are on the QA sites: source packages and Windows binaries. The final alpha for PHP 7.2.0 (third) will be published July 6th. Next comes the beta stage then Release Candidates. You can see the full release schedule plan here.

tagged: language alpha release php72 download

Link: http://php.net/index.php#id2017-06-22-1

SitePoint PHP Blog:
How to Set up an Online Multi-Language Magazine with Sulu
Jun 12, 2017 @ 12:17:01

The SitePoint PHP blog has a new tutorial posted by editor Bruno Skvorc showing you how to set up an online multi-language magazine with the help of the Sulu CMS. This article is a follow up to their previous "Getting Started" tutorial helping you get Sulu up and running.

We previously demonstrated the proper way to get started with Sulu CMS by setting up a Hello World installation on a Vagrant machine. Simple stuff, but can be tricky.

[...] This time we’ll look into basic Sulu terminology, explain how content is formed, created, stored, and cached, and look into building a simple online magazine with different locales (languages).

The tutorial then covers pages and page templates including what the Twig markup looks like, how to work with them in the UI and the end result of their sample "Hello world" page. There's a brief section about caching before he moves into the main part of the tutorial: the creation of the magazine. He covers the use of Jackalope, ElasticSearch and the ArticleBundle and how to get them up, running and playing nicely together. The article wraps up with a look at locales and how they work in the Sulu setup.

tagged: tutorial online multilanguage locale language magazine sulu cms

Link: https://www.sitepoint.com/set-online-multi-language-magazine-sulu/

PHP.net:
PHP 7.1.6 Released
Jun 09, 2017 @ 11:07:38

The PHP development team has officially announced the latest release in the PHP 7.1.x series for the language: PHP 7.1.6.

The PHP development team announces the immediate availability of PHP 7.1.6. Several bugs have been fixed. All PHP 7.1 users are encouraged to upgrade to this version.

Bugs fixed in this release are functionality related to MySQLi, Opcache, phar handling, xmlreader and the language core. As always, you can download this latest version either from the main downloads page (source) or from windows.php.net for the Windows binaries. If you're interested in the specific bugs that were fixed and the issues related, check out the full Changelog.

tagged: language release php71 bugfix

Link: http://php.net/index.php#id2017-06-08-3

Stitcher.io:
PHP Generics and why we need them
May 23, 2017 @ 09:48:56

On the Stitcher.io blog there's a post that's advocating the addition of a feature to the core PHP language that several others have: generics. The basic idea behind generics is to provide functionality that allows the definition of entity types that can be reused as a default (like a "collection" generic that could be used instead of a base collection class).

In today's blog post we'll explore some common problems with arrays in PHP. All the problems and issues listed could be solved with a pending RFC which adds generics to PHP. We won't explore in too much detail what generics are. But at the end of this read, you should have a good idea as to why they are useful, and why we really want them in PHP. So without further ado, let's dive into the subject.

They start off with a common use case in PHP: a collection of blog posts and getting information from them. There's no guarantee that the contents of the set are always post objects leading to specific checks to ensure data quality before use. The post then uses a common example from PHP, the creation of a collection class to handle a set of objects and then showing how (with pseudo-code as generics aren't in the language) how that same functionality might look defined as a generic collection instead.

tagged: generics language feature example rfc collection

Link: https://www.stitcher.io/blog/php-generics-and-why-we-need-them

PHP.net:
PHP 7.1.5 Released
May 12, 2017 @ 11:47:16

On the main PHP.net site they've posted the announcement about the latest release in the PHP 7.1.x series: PHP 7.1.5. This is a bugfix release and problems were fixed in:

  • core functionality
  • date handling
  • GD graphics functionality
  • internationalization
  • OpenSSL
  • phar creation

You can download this latest release from either the main downloads page (source releases) or windows.php.net for the Windows binaries. If you're curious about the full set of changes, you can check out the full Changelog for this release.

tagged: language release bugfix php71

Link: http://php.net/archive/2017.php#id2017-05-11-2

TutsPlus.com:
Working With PHP Arrays in the Right Way
Apr 26, 2017 @ 11:57:09

If you're relatively new to the PHP language and are just getting your feet wet, the massive amounts of array functionality included in the language could be confusing. This is where this new article on the TutsPlus.com site comes in, showing you how to work with PHP arrays "the right way".

n this tutorial, I am going to make a list of common PHP array functions with examples of usage and best practices. Every PHP developer must know how to use them and how to combine array functions to make code readable and short.

Also, there is a presentation with given code examples, so you can download it from the related links and show it to your colleagues to build a stronger team.

He starts out with some of the basics around using arrays in PHP and then quickly moves into other topics:

  • shortening code with functions like list
  • using the filtering functions
  • walking through array values
  • joining arrays
  • generating arrays
  • sorting the contents of arrays

He ends the post with a look at combining array functions to make it simpler to do things like remove empty values or return just the top three values.

tagged: tutorial introduction array functionality language

Link: https://code.tutsplus.com/tutorials/working-with-php-arrays-in-the-right-way--cms-28606

CloudWays Blog:
Phil Sturgeon Talks About API Development, PHP-FIG, PHP Books And The Future Of PHP
Apr 25, 2017 @ 12:34:44

On the Cloudways blog there's a new post sharing an interview with Phil Sturgeon with some of his thoughts about API development, the PHP-FIG organization, PHP-related books and the future of the language.

Today we are super excited to have Phil Sturgeon with us for this interview. Phil is a cool dude and an experienced API dev. He has a lot of experience in creating API for different platforms. Right now, he is working at WeWork as a Platform Engineer. He has written an excellent book on creating API, “Build APIs You Won’t Hate”. He has worked with popular PHP tools and frameworks including CodeIgniter, FuelPHP, PyroCMS. Phil also contributed to PHP The Right Way and PHP-FIG.

Phil also speaks at PHP conferences and often mentors budding developers. In this Interview he talks about his development experiences, workflows and experience with API development.

In the interview Phil answers questions about:

  • how he got started in PHP development
  • his opinions on PHP 7.x
  • preferred development workflows
  • his (previous) involvement with the PHP-FIG
  • his speaking and the topics he usually covers

Check out the full interview for answers to these and other questions.

tagged: cloudways interview philsturgeon development api phpfig books language

Link: https://www.cloudways.com/blog/phil-sturgeon-php-interview/