Simon HolywellFunctional Programming in PHP Second Edition Available Now (27.10.2016, 01:35 UTC)

It is with great pleasure that I announce the second edition of the Functional Programming in PHP book that I have been working on. There is twice the content of the first edition of the book as well as updates for PHP 7 and Facebook’s HHVM (HipHop Virtual Machine).

There are now more functional techniques and patterns included with pipelines, pattern matching and flat maps among them. I have added a section of the book dedicated to the handy syntax and functionality that HHVM can provide functional programmers with.

In addition I have, of course, listened to reader feedback and gone into a lot more detail about functions themselves, type signatures and their use, functional programming history and provided more examples of functional code in use. There is also a glossary of terms and appendices on libraries, REPLs and the frequently requested guide to using the UTF-8 ellipsis effectively in various editors.

On top of all that the book has been completely reorganised into a more logical structure with a better chapter breakdown.

So if you’re the kind of programmer who likes clean and easy to test code resulting in less bugs this is the PHP book for you. Even if functional programming isn’t really your thing all the techniques in the book will help you to become a better object oriented or procedural programmer.

To get your copy head on over to the books website for purchase links.

SitePoint PHPShopify App Development Made Simple with HTTP APIs and Guzzle (26.10.2016, 19:01 UTC)

In this tutorial, you're going to get started with developing Shopify apps. You're going to create a simple app that lists out products from a Shopify store. The full source code of the app is available on Github.

Shopify logo

What are Shopify Apps?

Shopify apps are a way of extending the functionality of a Shopify store or to provide ecommerce capabilities to websites or mobile apps. Here's a list of approaches to do this:

  • HTTP API - gives web apps the ability to perform different operations in a Shopify store. Things like adding a customer, getting a list of products, or listening for different events. This is done by means of webhooks.
  • JavaScript Buy SDK - allows you to fetch product information, add items to a cart and checkout either from a website or hybrid mobile apps such as those built with Cordova.
  • Embedded App SDK - allows you to embed your web app directly into the Shopify admin interface. This is useful for apps that have an admin settings page. Instead of the user having to access it on a separate website, the web app will be loaded as an iframe.
  • iOS and Android Buy - used for integrating Shopify checkout into your iOS or Android app.
  • Shopify POS App SDK - allows you to embed your web apps directly inside the Shopify POS.

In this tutorial, you're going to learn about the HTTP API.

Sign up for a Shopify Partner Account

The first thing that you need to do is to sign up for a Shopify Partner Account. This allows you to create a development store for testing a Shopify app. You will be asked to fill out a form with things like your company name, business type, email address, website, password and other relevant information.

Shopify Partner Signup

If all the information you provided is valid, you should be greeted with the following page:

Shopify Partner Success Page

Create a Development Store

The next step is creating a development store which is like a Shopify store. You can add products, store HTML and CSS code for themes, and test purchases through a bogus payment gateway. The only limitation is that you can't add a custom domain or charge customers in a development store.

Click the Create a development store button and you will be redirected to the following page:

Create Development Store

Add the store name, the password for logging in to the store (your Shopify partner email address is the login email), and the kind of store to create. Stick with an Online store for now. This gives you the ability to build custom themes, develop an app, or set up your client's online store. Once you're done with filling the form, click the Create Store button to create the development store.

Continue reading %Shopify App Development Made Simple with HTTP APIs and Guzzle%

PHP ClassesHow to Validate Email Blacklisting Disposable Temporary Addresses (26.10.2016, 16:34 UTC)
By Suresh Kumar
Disposable email addresses are temporary addresses used by some people to access certain sites without using their real addresses.

Since these addresses prevent that the sites contact the users to send relevant information by email, it is useful for sites to prevent accepting this kind of addresses.

Read this article to learn how to validates temporary email addresses by blacklisting well known domains of disposable email address providers.
Nomad PHPWrite More Expressive Tests with Hamcrest PHP (26.10.2016, 15:05 UTC)

Speaker: Gareth Ellis @garethellis Have you ever struggled to write expressive, easy-to-read test assertions in PHP? If so, then Hamcrest PHP could be the answer. In this talk, I’ll show you how to use Hamcrest to make your test assertions a positively pleasant experience, and cover how you can create your own custom matchers for …

The post Write More Expressive Tests with Hamcrest PHP appeared first on Nomad PHP.

Davey ShafikI’m Sorry… (26.10.2016, 06:14 UTC)

Some of you may have noticed that I was absent from several events over the last month, specifically, DrupalCon Dublin, PHPNW, and BulgariaPHP.

I had intended to fly from my home to Dublin, before hopping over to Manchester, and then finally on to Sofia before coming back home again.

I was stoked to attend my first ever DrupalCon, to be going back home for the excellent PHPNW, and ending my trip with my favorite conference of 2015, BgPHP. It was going to be amazing.

And I couldn’t do it.

I did a lot of travel last year, and it was amazing. And tiring. I decided this year to do less travel, and I think that objectively, I have. However, this year is the first time my son has also cried when I’ve left, and my travel has been bunched up such that I’ve been away on several long trips.

I had just completed an unexpected West-East-West-East-West (SEA (Home) -> BUF (CodeDaze) -> SEA (PNWPHP) -> JFK (Velocity) -> SEA (Home)) and it was exhausting.

So, as I got up, said goodbye to my family, and loaded my stuff in my cab to the airport, I was anxious about being away for yet another extended period of time.

We started our drive to the airport, and I used my time to share my feelings with some friends via Twitter… and it became clear to me that I was either experiencing, or close to burnout.

Despite my embarrassment, I had my driver turn around and take me home. I cancelled my flights, my hotels, and told my boss. I contacted DrupalCon and went to bed. After I got up again, I contacted PNWPHP, and yet… I still hoped to make BgPHP. I thought maybe I could get my shit together in 5 days or so and still make the event I’d been looking forward to all year. But no… I couldn’t. And so, a few days later I told them too.

For those wondering, my emails were something like this:

Hi Ramelina (and the rest of the BgPHP crew),

As you know BgPHP is my absolute favorite conference in the entire world… however, I won’t be able to make it this year :(

After scaling back my travel due to mental health reasons I’m no longer able to attend :(

I understand that this is less than ideal for you and the wonderful attendees, and I’d like to do anything possible to make it easier for you.

Please let me know if I can be of any help, and if there any costs (such as hotel) that I need to cover.

I’m really sorry :(

And you know what? Everyone was fantastic. Nobody got mad, nobody was upset, they all just wished me well, and I’m sure scrambled to fix the mess I had made. And I am eternally grateful.

And dreadfully sorry.

I am sorry to the organizers, of course, but also to the attendees and wider community. As a Developer Advocate, I would like to be relied on by conference organizers and the community, as a known entity of stability. This is why, for example, I always let organizers know I have other talks I can give if someone else can’t speak for any reason. This is why I try to always get in early, and I work so hard on my slides.

I’m currently writing this from Berlin, and in truth, there was still a bit of anxiety leaving for this trip (with Akamai Edge in San Francisco first) — but, I’m glad I did it, if only to prove to myself that I still can.

Thank you, to every one who reached out to me when they heard I wasn’t going to make it, and in person this week, it meant a lot to me.

I will try to do better.

Photo by GPS, used under a CC-BY-SA 2.0 License.

Voices of the ElePHPantInterview with Larry Garfield (25.10.2016, 10:00 UTC)
Larry Garfield

Show Notes

More from this guest

See Larry’s talks, Functional PHP, and Make Your Code Do Your Job on Nomad PHP

The post Interview with Larry Garfield appeared first on Voices of the ElePHPant.

Evert PotSwitching to Google AMP and back (25.10.2016, 04:26 UTC)

A few months ago I added support for AMP to this blog. Not that it desperately needed it, but the premise seemed interesting and I figured it would be good to get some experience with new technology. The real selling point for me is how fast this website would appear in search results.

The switch to AMP

This website is built with Jekyll, hosted on Github pages, and behind a Cloudflare proxy. Why cloudflare? Same reason for using AMP! Websites are pretty much my business, and I want my own home to be powered by both TLS and HTTP/2!

What this meant for AMP though is that I had to change my main site into an AMP site. Dynamic websites unlike this might be able to create both an AMP and non-AMP website.

In practice these are the things I had to do:

  • Inline stylesheets. This was fairly easy with jekyll, I just had to change my linked stylesheets to an {% include .. %}.
  • Add a bunch of AMP boilerplate.
  • Add JSON-LD in my website header. The AMP website says it’s not required, but without it you’re not going to get AMP support in google results.
  • Changing all <img> tags to <amp-img> tags.
  • Removing all javascript. The only bits of JS I had was for google analytics, which gets replaced with <amp-analytics>.
  • And.. Disqus. This was a bit harder to solve.


Disqus requires javascript. I figured the best solution for using Disqus with AMP is to have the Disqus comment box run in an iframe. This created a few more challenges:

AMP doesn’t allow javascript, but it does allow iframes using <amp-iframe>, but there’s a caveat. If you want to run javascript inside that iframe, the iframe has to be hosted on a different domain for security reasons.

I tried to trick it with some domain variations, and a redirect, but had no luck. I ended up creating a separate github repository specifically for serving my Disqus comments.

This worked, but there was a second issue. Disqus itself also uses an iframe to embed comments. To ensure that this Disqus iframe is large enough, it will dynamically resize based on its contents.

I had to do something similar. I had to detect when the inner Disqus iframe resized, so I could resize the outer amp iframe. I had trouble doing this with my usual javascript events. After I while I realized that Disqus itself must send a message from the iframe to the top document. I figured it would likely do this with the postMessage javascript API. And I was right!

So all I had to do is listen for the resize messages the Disqus application sends out, and then forward the resize messages to the AMP document. A total hack, but here is a snippet:

window.addEventListener('message', function(ev) {
    if (String(!=='{') {
        // Not a disqus event
    var data = JSON.parse(;
    if ( !== "resize") 

Truncated by Planet PHP, read more at the original (another 4971 bytes)

Matthew Weier O'PhinneyAutomating PHPUnit with Node (24.10.2016, 20:25 UTC)

I've been trying to automate everything this year. When working on OSS, this is usually as simple as setting up Travis CI; in some cases, even that becomes a little more involved, but remains possible.

But that's continuous integration. What about continuous development?

Continuous development?

With continous integration, every time I push to a branch associated with a pull request or on the origin repository, a build is triggered. Which is great, because I can verify and validate that my code runs fine on all the target platforms. But I have to wait for the build to trigger and then run.

Ideally, I should also be testing locally; I likely don't want to push anything upstream that will fail! So, I look in the contributing guidelines, and determine how to run coding standards checks and unit tests, and do those manually.

Manually? Ugh. Too easy to forget, and too easy to lose track and make a ton of changes between runs, making breakage easier.

I'd like to automate running these as part of my development process. I want continuous development cycles.

Preparing your project

The first step is preparing your project. I like to run my tests and CS checks using Composer, as that allows me to change what I'm using later, but also allows me to standardize invocation of the tools. I define the following scripts in my composer.json:

"scripts": {
  "check": [
  "cs-check": "phpcs --colors",
  "cs-fix": "phpcbf --colors",
  "test": "phpunit --colors=always"

You may, of course, need to alter these to use the tools specific to your own project. The main thing is that you have a "check" target, which runs all the various QA tools.

You don't need to do this. But I definitely recommend it. If you can simplify invocation for your users, and for your tools, automation is far easier.

Using gulp

Node has some great tools for watching the filesystem and reacting to it. Two of these are considered "build" or "workflow" tools: Grunt and Gulp.

I've opted for Gulp here, as the setup is far simpler; that said, it's not difficult to do in Grunt, either.

First, you'll need npm, which usually comes packaged with node, or yarn, a more recent addition to the node ecosystem. Once you have these, you can continue.

Second, I installed a few dependencies:

  • gulp is the actual taskrunner. It needs to be installed both globally, and locally. It includes the functionality for watching the filesystem.
  • gulp-shell provides the ability to execute arbitrary command line tools.
  • gulp-notify ties into your system's notifications abilities.

Navigate to your project directory, and install these as follows:

$ npm install -g gulp # this may require sudo, depending on your system
$ npm install --dev gulp gulp-shell gulp-notify

If you are using yarn:

$ yarn global add gulp # this may require sudo, depending on your system
$ yarn add --dev gulp gulp-shell gulp-notify

Third, create the following gulpfile.js in your project:

/* jshint: node: true */
var gulp = require('gulp');
var notify = require('gulp-notify');
var shell = require('gulp-shell');
var project = require('path').posix.basename(__dirname);

gulp.task('default', ['watch']);
gulp.task('php_check', function () {
    .pipe(shell('composer check'))
    .on('error', notify.onError({
      title: project + ' failures',
      message: project + ' CS checks and/or tests failed'
gulp.task('watch', function () {
    ['phpunit.xml.dist', 'phpcs.xml', 'src/**/*.php', 'test/**/*.php'],

What the above does is:

  • Watch the filesystem for changes to any of:
    • phpunit.xml.dist, which would indicate a change to the test runner behavior.
    • phpcs.xml, which would indicate a change to the coding standards.
    • PHP files found in either the src/ or test/ directories.

Truncated by Planet PHP, read more at the original (another 4483 bytes)

SitePoint PHPIs It Possible to Write and Run PHP Code on an iPad? (24.10.2016, 17:00 UTC)

I love the iPad. It's a fantastic form factor for media consumption and gaming; and it also works well as an e-reader. The trouble is I don't use it nearly as much as I could. Most of the time I'm consuming media (Netflix, Twitch, YouTube), I'm coding in parallel.

I can do that on my MacBook, but I've never been able to do that until now. Two things have made it possible:

  1. iOS recently added support for picture in picture playback. That means I can keep a video app playing, while working on something else.

  2. Fantastic apps (like DraftCode and Working Copy) make it possible to code and run PHP apps, and push changes to Github, directly from the iPad.

Picture in picture

Today I'm going to show you how I code on an iPad. I won't pretend it's a perfect workflow (what workflow is?), but this is as exciting for me as the first time I used a laptop instead of a desktop.

I started writing this post a while ago. To tell you the truth, I don't think the apps I've going to talk about were ready then. They've both received updates since. It's as though the developers could hear inside my brain, and wanted to make me happy. I also apologize for the size of this page; there are many animated gifs..


One of the most important parts of this whole experiment, is finding the right keyboard. When it comes to mobile devices, there's no shortage of poor-quality hardware.

I searched for quite some time before I settled on a keyboard I liked the look of. I can safely say I made the right choice.

This keyboard is about twice the length of the iPad Mini 2, and weighs about the same. The keys feel amazing, with plenty of space between them. And it's quiet!

This keyboard also has a trackpad. iOS doesn't support mouse or trackpad (as far as I'm aware), so you don't have to go with a keyboard that has a trackpad. I like this because it can double as an input device for my Raspberry Pi (using a single USB port for keyboard and trackpad).

Unless you're using a Bluetooth keyboard, you're going to need a USB port. Fortunately, Apple produce an adapter (originally made for digital camera compatibility), that works wonderfully with every USB keyboard I've ever tried.

The Windows key doubles as a command key, and Windows + z / Windows + x / Windows + c / Windows + v all work as you're used to. You can also use Windows + → and Windows + ← to move to the beginning and end of lines.

The All-in-one Media keyboard is listed as USD 39.95 on the Microsoft website, but you can pick it up for USD 29.99 on Amazon. The Lightning USB adapter is listed as USD 29.99 on the Apple website, and actually costs a couple dollars more from Amazon.


I've already mentioned a couple of apps (DraftCode and Working Copy), and the truth is these are the only two you need.

What tools do you use to code? You probably use an IDE (or at the very least a text editor, like Atom). You probably use something like Git, to organize and version your source code.

Continue reading %Is It Possible to Write and Run PHP Code on an iPad?%

PHP ClassesHow to Stream Your PHP Code on (24.10.2016, 08:41 UTC)
By Danilo Bilandzija is a live streaming platform that allows people to share code, exchange programming experiences, and socialize, while improving their code.

Read this article to learn how you can expose your PHP programming skills while you program live, as well how you can embed your recording live streaming videos in PHP Classes, so other PHP Classes users can learn how you are doing your work.
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP