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

QaFoo.com:
Never Use null
May 03, 2016 @ 13:07:32

On the QaFoo.com blog they've made a recommendation in their latest post - they suggest that you never use null.

When doing code reviews together with our customers we see a pattern regularly which I consider problematic in multiple regards – the usage of null as a valid property or return value. We can do better than this.

Let's go into common use cases first and then discuss how we can improve the code to make it more resilient against errors and make it simpler to use. Most issues highlighted are especially problematic when others are using your source code. As long as you are the only user (which hopefully is not the case) those patterns might be fine.

They talk about some of the most common uses they see for using null in PHP applications including setters for class properties (injection). They point out that in PHP 7 a missing value on a property would result in a Fatal error and make the functionality harder to test overall. They suggest that all required dependencies be injected on object construction instead, making it easier to know the current state of the object on testing. They also talk some about using null as a return value, how it could make debugging difficult and a solution that could make more sense - throwing an exception instead.

tagged: never use null return value injection setter solution suggestion debugging

Link: https://qafoo.com/blog/083_never_use_null.html

php[architect]:
May 2016 Issue Released - Full Speed Ahead
May 03, 2016 @ 12:18:25

On the php[architect] site today they've announced the release of their May 2016 issue: "Full Speed Ahead".

We’ve just released the May 2016 issue of php[architect] magazine. To help you make good use of your development time, this month the magazine looks at libraries including DoctrineORM and FastRoute, and product development lessons from building Laravel Shift.

In addition, this month includes articles on defining “Senior Developer”, the value of gratitude, keeping credentials safe, securing web services, and the value of hindsight.

This month's issue also includes articles covering OAuth 2 and all of the usual columns (Education Station, Leveling Up, Community Corner, Security Corner). As always they provide one article free so you can get a taste of the latest issue. This time it's the article from Edward Barnard covering web services security. You can pick up a copy of your own directly from the php[architect] website or just get a year long digital or print subscription while you're there.

tagged: phparchitect magazine may2016 fullspeedahead issue release

Link: https://www.phparch.com/magazine/2016-2/may/

CloudWays Blog:
“PHP 7 Has Done Wonders For The Language”, Says Stefan Koopmanschap Of PHPBenelux
May 03, 2016 @ 11:29:22

The Cloudways.com blog has posted their latest interview with a member of the PHP community. In this new interview they talk with Stefan Koopmanschap about some of his background in development and thoughts about the community and language.

Stefan is the co-founder of PHPBenelux and speaker of many PHP conference around the world. He has a vast experience of development. He was the community manager of Symfony framework. Stefan is the Zend Certified and have also contributed in Zend Framework. He is the co-founder and trainer at Tech Academy and the podcast host at Dutch Web Alliance.

In his interview with Cloudways Stefan talks about his career start, share his experience as a speaker. What he contributed in Zend Framework. Comparing NodeJS with PHP 7 and Zend with Symfony. Giving advice to students and telling us which people to follow in PHP community.

In the interview Stefan answers questions about:

  • How he started out his career as a developer and mentors that helped
  • Speaking at conferences and where he got his start
  • Thoughts comparing Zend Framework and Symfony
  • His avid use of GitHub
  • Recommendations of people to follow in the community
  • Advice to beginners just starting in the language

They also mention Stefan's other passion - DJing for On Air Radio - and how he got started there. You can read the answers to these and other questions in the full interview.

tagged: cloudways community interview stefankoopmanschap

Link: http://www.cloudways.com/blog/stefan-koopmanschap-interview/

Mark Baker:
In Search of an Anonymous Class Factory
May 03, 2016 @ 10:49:25

In a new post to his site Mark Baker take a look at anonymous classes, a new feature in PHP 7, and a challenge he took on to figure out how to apply traits to them at runtime.

One of the more interesting new features introduced to PHP with the arrival of version 7 is Anonymous Classes. [...] Then back in January (as I was waiting for my flight to the continent for PHPBenelux) I was intrigued by a request to find a way of dynamically applying Traits to a class at run-time. With time on my hands as I was sitting in the airport, I considered the problem.

His first idea was to build an anonymous class, extending the requested class that would come along with the traits/properties/functionality of the original class. He includes some of the code he tried to implement this solution and ultimately figured out that a factory would be a good approach to creating the structure. After doing some research he found a way to create the factory using some eval magic. However, this wasn't "the end of the story" as he found out some other interesting things about anonymous classes (such as the fact that they're linked to only one instance of a class, making them less reusable).

tagged: anonymous class php7 factory eval example

Link: https://markbakeruk.net/2016/05/03/in-search-of-an-anonymous-class-factory/

Free the Geek Podcast:
Episode 17 - Talking Conferences and Security with Chris Cornutt
May 03, 2016 @ 09:45:26

The Free the Geek podcast, hosted by PHP community member Matthew Setter, has posted their latest episode - an interview with Chris Cornutt about conferences and security topics.

In this episode I chat with Chris Cornutt, founder of PHPDeveloper.org, websec.io, and Lone Star PHP about conferences and all things security.

It’s a rousing chat about the state of security within the PHP and wider development community. He also gives me an inside look at what it’s like to run the long-running Lone Star PHP conference in Texas. Grab your favourite beverage and your comfy chair, and get ready for a rousing fireside chat with Chris and I.

You can listen to this latest episode either through the in-page audio player or by downloading the mp3 of the show for listening at your leisure. If you enjoy the episode be sure to subscribe to their feed and follow them on Twitter for updates when the latest episodes are released.

tagged: freethegeek ep17 chriscornutt episode conference security

Link: http://freethegeek.fm/episode/episode-0017

Community News:
Latest PECL Releases (05.03.2016)
May 03, 2016 @ 08:05:02

Latest PECL Releases:

  • ibm_db2 1.9.9
    Enhanced: Added PHP 7 support and fixed linking error.

  • ibm_db2 1.9.8
    Enhanced: Added PHP 7 support.
  • mongo 1.6.14
    ** Bug * [PHP-1468] - Segfault on node with high network latency * [PHP-1511] - append_getlasterror() should ignore unset fsync/journal from link

    ** Improvement * [PHP-1510] - Route unacknowledged writes through legacy op codes

  • amqp 1.7.0
    * Add PHP7 support (Bogdan Padalko, Steffen Hanikel) * Add AMQPEnvelope::hasHeader(), AMQPExchange::hasArgument() and AMQPQueue::hasArgument() to check whether specific header exists (Bogdan Padalko) * Fix AMQPConnection::setPort() writes to wrong property (Bogdan Padalko) * Add compiled librabbitmq version early check (Bogdan Padalko) * Fix segfault when channel zval type != IS_OBJECT (Bogdan Padalko) * Fix API breakage when rabbitmq-c < 0.6.0 used (Bogdan Padalko) * Close connection on library errors (Bogdan Padalko) * Do not store connection resource ID string (Bogdan Padalko) * Explicitly cleanup references on connection on cleanup (Bogdan Padalko) * Show effective connection values when connection is active and passed values otherwise (Bogdad Padalko) * Completely move to zend object custom objects (AMQPEnvelope, AMQPExchange and AMQPQueue) (Bogdan Padalko) * Use zend object on custom objects for properties storing (AMQPConnection and AMQPChannel) (Bogdan Padalko) * Fix not properly deleted connection resource. (Bogdan Padalko, Steffen Hanikel) * Fix not properly allocated and freed amqp_table_t arguments table memory. (Bogdan Padalko, Steffen Hanikel) * Upgrade vagrant box to Ubuntu 15.10 Wily Werwof (Bogdan Padalko) * Fix various grammar and spelling mistakes (Artem Gordinsky) * Update stubs (Sascha-Oliver Prolic)

    For a complete list of changes see: https://github.com/pdezwart/php-amqp/compare/v1.6.0...v1.7.0

tagged:

Link:

Marc Schmidt:
PHP High-Performance - Follow Up with Symfony/Jarves.io and PHP-PM
May 02, 2016 @ 12:08:37

In a follow up to his previous article about high performance PHP with React's help, Marc Schmidt has returned with a follow up post two years after the fact with some updates and additional information.

This is a follow up article on “Bring High Performance Into Your PHP App”, which went quiet viral with over 100k visits. This does not only show that many people still struggle with PHP and its performance, but also that people are highly interested in a solution to this kind of issues. PHP-PM could be one solution. But first things first. Over two years later since my blog post about high-performance things have changed dramatically.

[...] When I hacked together some lines of code back then in 2013 I never though that this kind of application style would ever succeed in the PHP world. [...] However, things have changed there as well.

He talks about some of the advancements that have been made since his previous post including PHP 7, improvements in PHP-FM and the HttpKernel component of the Symfony framework. Along the lines of bringing even more performance to PHP applications with React, they created an adapter to link the two. The post covers some of the currently open issues, the "good things" about it and some of the design issues to keep in mind when using it. He ends the post talking about where the PHP-PM project is now and some of the benchmarks about performance between PHP-PM and PHP-FPM.

tagged: performance react httpkernel phppm phpfpm adapter benchmark

Link: http://marcjschmidt.de/blog/2016/04/16/php-high-performance-reactphp-jarves-symfony-follow-up.html

SitePoint PHP Blog:
Starting a Business with Laravel Spark
May 02, 2016 @ 11:51:22

On the SitePoint PHP blog there's a new tutorial from Christopher Pitt showing you how to "start a business" with Laravel Spark, the recently released scaffolding product that takes care of a lot of the typical "business" handling for online products.

I am really excited about Laravel Spark. By the time you read this, there will probably be a multitude of posts explaining how you can set it up. That’s not as interesting to me as the journey I’m about to take in creating an actual business with Spark!

The idea is simple. I have created a Pagekit module which you can use to back up and restore site data. The module makes it easy to store and download these backups, and restore them on different servers.

He starts off with some of the background behind the product and getting Spark set up with some additional functionality (like additional user fields and gathering billing information). He then creates the functionality allowing for the actual storing of the backups and API functionality that integrates with it. The post wraps up with his look at adding the code needed to download the backups and return them back to the user.

tagged: laravel spark tutorial business pagekit backup tutorial introduction

Link: http://www.sitepoint.com/starting-a-business-with-laravel-spark/

TutsPlus.com:
Kick-Start WordPress Development With Twig: Timber Image, Menu, and User
May 02, 2016 @ 10:51:47

The TutsPlus.com site has posted the next part of their series looking at integrating WordPress and Twig with a look at showing images, menus and users in your WordPress UI.

By now you have read about the basic concepts of using Twig through Timber, while building a modular WordPress theme. We've also studied block nesting and multiple inheritance with Twig, based on the DRY principle. Today, we are going to explore how to display attachment images, WordPress menus, and users in a theme with Twig through the Timber plugin.

They go through each of the topics (images, menus and users) and provide the code needed to both gather the data needed and the templates to render the views. This all makes heavy use of the Timber functionality to integrate it with the overall WordPress structure. Screenshots are also included of the resulting output to help you ensure things are working as expected.

tagged: kickstart wordpress development twig timber tutorial series part5

Link: http://code.tutsplus.com/articles/kick-start-wordpress-development-with-twig-timber-image-menu-and-user--cms-25750

Symfony Finland:
Exotic PHP implementations: HippyVM, JPHP, Tagua VM, Peachpie
May 02, 2016 @ 09:15:37

On the Symfony Finland blog they have a recent entry looking at some of the other alternative PHP implementations with a brief overview of each.

In the past there have been alternative environment for running PHP in PIPP for Parrot VM and Quercus for JVM, but none of these have had real staying power. This changed with HHVM from Facebook in the early 2010's. It's completely separate from the Zend PHP implementation and is a fully featured alternative.

[...] Many the implementations are just proof of concept implementations and are far from supporting all the language features and rendering them to be useless for running Symfony or other contemporary applications. Regardless of whether these are immediately useful for projects it's interesting to follow these efforts.

The four covered in the post allow for PHP to be run in some pretty non-traditional environments:

There's a brief look at each of these projects included and, while most aren't close to what HHVM has to offer, you might take a look and see if they could be interesting to try out in some of your development.

tagged: implementation alternative hippyvm jphp taugavm peachpie overview

Link: https://www.symfony.fi/entry/exotic-php-implementations-hippyvm-jphp-tagua-vm-peachpie