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

TutsPlus.com:
Deploy Your PHP Application With Rocketeer
May 04, 2016 @ 14:19:01

On the TutsPlus.com site there's a new tutorial posted that aims to help you deploy your PHP application with Rocketeer, a PHP-based deployment tool with lots of built in functionality for more complex deployments.

There used to be a time when PHP developers had to use deployment tools that were aimed at general web applications. [...] But nowadays, we're blessed with a few deployment tools written in our language that enable deeper integration. One of these tools is Rocketeer, a tool that takes inspiration from Capistrano and the Laravel framework.

Rocketeer is a modern tool that brings a great approach for your deployment needs. That is to run tasks and manage your application across different environments and servers.

They start with a brief introduction to the Rocketeer tool (basically a SSH driven command execution engine) and show you how to get it installed on your system. They then help you initialize the setup directory (.rocketeer) and describe each of the pieces and how the deployment happens. They show you how to configure events and tasks in the system to perform during execution. They also show the definition of "strategies" to execution events/tasks in groups, work with plugins and, finally, running an example deployment.

tagged: rocketeer deployment tool introduction configuration example

Link: http://code.tutsplus.com/articles/deploy-your-php-application-with-rocketeer--cms-25838

Mark Ragazzo:
Immutable objects
May 04, 2016 @ 13:55:42

In a post to his site Mark Ragazzo looks at immutable objects - what they are and how they can be used in a PHP application with some "final" functionality.

In this short article we will see what immutable objects are and why we should consider to use them. Immutable object is an object that does not change its state after it was created. Immutable objects usually are very simple. You may already seen them as enum types or primitives like DateTimeImmutable.

Further in this article you will learn that making simple objects immutable may save significant amount of your time by making impossible to make certain types of mistakes.

He starts with a list of a few things to remember when implementing immutable objects (like using the "final" keyword) and problems that can come without them. He then gets into some examples, showing how to create immutable Address and Money objects and how to use them when you need to update/get values from the object. He also covers some common "accidental mutability" cases like leaking internal object references and inheritance problems.

tagged: immutable object introduction example mutability accidental tutorial

Link: https://ragazzo.github.io/immutability/oop/2016/05/03/immutability.html

SitePoint PHP Blog:
Building a SparkPost Client: TDD with PhpUnit and Mockery
May 04, 2016 @ 12:26:32

On the SitePoint PHP blog they've continued their series covering the SparkPost mail delivery service and integrating it in to your application. In this latest part of the series author Christopher Pitt starts looking at the SparkPost API and uses it as a chance to practice some TDD (Test Driven Development) skills.

In a previous post, we looked at SparkPost (as an alternative to Mandrill), and explored a bit of the official PHP client. The official client handles a decent amount of work, but I got to thinking about what it would take to build a new client.

The more I thought about it, the more it made sense. I could learn about the SparkPost API, and practice Test Driven Development at the same time. So, in this post we’ll look to do just that!

He uses a few different libraries to explore the API and its endpoints: Guzzle for the HTTP requests and the Mockery+PHPUnit combination for the testing. He includes the setup and configuration for the testing environment and some sample tests for making sure things are connected. He then integrates Mockery into the testing, using it to mock the Guzzle requests and still have the tests pass even without the actual connection. He then works through several other tests and finishes the post with a mention of building coverage results for the "Client" class.

tagged: sparkpost client tutorial series tdd testdriven development mockery phpunit guzzle api

Link: http://www.sitepoint.com/building-a-sparkpost-client-tdd-with-phpunit-and-mockery/

Voices of the ElePHPant:
Interview with Rachel Baker
May 04, 2016 @ 09:41:09

The Voices of the ElePHPant podcast has posted their latest interview with a member of the PHP community. In this new episode (another video interview from php[world] 2015) host Cal Evans talks with Rachel Baker, a developer on the WordPress API project

They talk about why and when the REST API project was started up and some about the current status of the work (mostly moved into core). Rachel also fills Cal in on why it migrated from the "JSON API" over to to the "REST API" to help prevent some confusion between it and other features. They also spend some time talking about some of the merging of developer communities an open API can help foster (like between the wider PHP community and the WordPress community).

You can listen (or watch) this latest episode either through the in-page players, both video and audio, or you can download the mp3 if you want to listen to the audio offline. If you enjoy the episode, be sure to also subscribe to their feed and follow them on Twitter to get updates as new episodes are released.

tagged: voicesoftheelephpant community interview rachelbaker podcast

Link: https://voicesoftheelephpant.com/2016/05/03/interview-rachel-baker/

Community News:
Recent posts from PHP Quickfix (05.04.2016)
May 04, 2016 @ 08:05:02

Recent posts from the PHP Quickfix site:

tagged:

Link:

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