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.
Liip Drupal SearchAPI and result grouping (24.10.2016, 07:17 UTC)

In this blog post I will present how, in a recent e-Commerce project built on top of Drupal7 (the former version of the Drupal CMS), we make Drupal7, SearchAPI and Commerce play together to efficiently retrieve grouped results from Solr in SearchAPI, with no indexed data duplication.

We used the SearchAPI and the FacetAPI modules to build a search index for products, so far so good: available products and product-variations can be searched and filtered also by using a set of pre-defined facets. In a subsequent request, a new need arose from our project owner: provide a list of products where the results should include, in addition to the product details, a picture of one of the available product variations, while keep the ability to apply facets on products for the listing. Furthermore, the product variation picture displayed in the list must also match the filter applied by the user: this with the aim of not confusing users, and to provide a better user experience.

An example use case here is simple: allow users to get the list of available products and be able to filter them by the color/size/etc field of the available product variations, while displaying a picture of the available variations, and not a sample picture.

For the sake of simplicity and consistency with Drupal’s Commerce module terminology, I will use the term “Product” to refer to any product-variation, while the term “Model” will be used to refer to a product.

Solr Result Grouping

We decided to use Solr (the well-known, fast and efficient search engine built on top of the Apache Lucene library) as the backend of the eCommerce platform: the reason lies not only in its full-text search features, but also in the possibility to build a fast retrieval system for the huge number of products we were expecting to be available online.

To solve the request about the display of product models, facets and available products, I intended to use the feature offered by Solr called Result-Grouping as it seemed to be suitable for our case: Solr is able to return just a subset of results by grouping them given an “single value” field (previously indexed, of course). The Facets can then be configured to be computed from: the grouped set of results, the ungrouped items or just from the first result of each group.

Such handy feature of Solr can be used in combination with the SearchAPI module by installing the SearchAPI Grouping module. The module allows to return results grouped by a single-valued field, while keeping the building process of the facets on all the results matched by the query, this behavior is configurable.

That allowed us to:

  • group the available products by the referenced model and return just one model;
  • compute the attribute’s facets on the entire collection of available products;
  • reuse the data in the product index for multiple views based on different grouping settings.

Result Grouping in SearchAPI

Due to some limitations of the SearchAPI module and its query building components, such plan was not doable with the current configuration as it would require us to create a copy of the product index just to apply the specific Result Grouping feature for each view.

The reason is that the features implemented by the SearchAPI Grouping are implemented on top of the “Alterations and Processors” functions of SearchAPI. Those are a set of specific functions that can be configured and invoked both at indexing-time and at querying-time by the SearchAPI module. In particular Alterations allows to programmatically alter the contents sent to the underlying index, while the Processors code is executed when a search query is built, executed and the results returned.
Those functions can be defined and configured only per-index.

As visible in the following picture, the SearchAPI Grouping module configuration could be done solely in the Index configuration, but not per-query.

SearchAPI: processor settings

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

Stefan KoopmanschapZendCon 2016 (21.10.2016, 03:30 UTC)

It's just past 5AM as I start writing this. I'm sitting downstairs in the ZendCon hotel, with a view on an empty bar and brightly coloured gambling machines. Since I woke up at 3AM (don't you love jetlag?) and today is the day I travel back home, I've been reflecting on the conference. I'll be missing a few sessions because I had to leave early, but I've already gotten a lot of new stuff to ponder about, my head is pretty full. Time to let it sink in a bit.

As I was pondering the lessons of this conference, I thought back to the last talk of yesterday, Exploiting the brain for fun and profit by Alena Holligan. One of the things Alena talked about was how you can improve your learning. One of the things she mentioned was teaching others. Teaching others really helps you to learn stuff yourself. But the other thing was: Write it down. Writing things down will help you to not forget stuff. She even mentioned the situation I've been in a couple of times: Googling for a problem only to end up on your own blog, where you discuss the solution. As such, I'm writing down some of my lessons of ZendCon. So I won't forget, and hopefully to help others learn about this stuff as well.

Let's start with the opening keynote by Andi Gutmans and Rod Cope. Andi and Rod looked back at where we came from and where we're going with technology. While the picture for the future that was painted sounded awesome for users, it sounded horrible for privacy. I'm really curious to see where this will be going.

I also attended the Composer for corporate use talk that Stephan Hochdörfer did. One of the things I learned from that talk is the composer license command, which gives you an overview of the licenses used by your dependencies. Related to that, I also learned about VersionEye, which seems like an interesting service. That is now on my list of things to check out.

I was really looking forward to see Uncle Bob do a keynote at ZendCon, and this turned out to be an amazing keynote. He gave a nice overview of some common patterns from the past as well as the present. It also taught me that at my current project we're doing pretty well for some of these topics. There's always room for improvement, but we're on the right track. It is good to get that kind of confirmation.

Next to the talks I also had a nice chat with some of the sponsors at their booths. My most important lesson there was the Clean Coders video platform. Before ZendCon I was not aware it even existed, but with a lot of material delivered by people like Uncle Bob, Corey Haines and Michael Norton on topics such as architecture, technical debt, testing, SOLID etc it looks like an amazing opportunity.

It has been another amazing ZendCon, and I'm bringing the lessons back home with me.

Nomad PHPIncorporating Custom PHP Code in Fabrik Website Applications (20.10.2016, 17:21 UTC)

Speaker: Robbie Adair @robbieadair Fabrik is a custom application builder that works inside of Joomla! websites. The structure allows for non-coders to build basic applications and PHP developers to add custom code throughout to create more complex applications. We’ll take a quick look at the various areas where coders can add their PHP snippets or …

The post Incorporating Custom PHP Code in Fabrik Website Applications appeared first on Nomad PHP.

SitePoint PHPTesting PHP Code with Atoum – an Alternative to PHPUnit (20.10.2016, 17:00 UTC)

If you’ve been around PHP for more than a little while, you’ve no doubt started to test your code. And if you ask anyone in the PHP space what to use for writing unit tests, likely the first answer that they’ll give you is PHPUnit.

It’s the de facto standard in the PHP community, and with good reason. But it’s not the only choice. Whilst it does command the lion’s share, other choices abound, one of which I’m going to take you through in this tutorial; it’s called atoum.

If this is your first time hearing about it, it is self-described as:

A simple, modern, and intuitive unit testing framework for PHP!

Atoum logo

I can’t necessarily vouch for it being all that intuitive, but it definitely is reasonably simple to use. And whilst its composer.json currently specifies a minimum version of PHP 5.3.3, one of the core developers told me that from version 3.0 support for PHP 5.3 will be officially dropped in favor of PHP 5.6. So don’t be fooled, it is a modern take on testing in PHP.

Recently, I decided to give it a test run on an existing codebase of mine, a health monitoring application which I’ve been writing to help me deal with some health problems I’ve had over the last 12 - 24 months. I found it to be an interesting take on software testing, combining several different styles into the one package.

Installing Atoum

Like all modern PHP software, we install it with Composer.

composer require atoum/atoum

For the purposes of this tutorial, I’ll assume that you’re following along using PhpStorm. No offense meant to Vim, Emacs, and other editors.

Given that, and given how atoum’s source code is structured, we should also install a supplementary library called atoum/stubs.

Without it, attempting to perform any kind of code completion in your IDE with atoum is less than straight-forward. Stubs make working with atoum much more user-friendly, as the graphic below will attest.

Using atoum stubs with PhpStorm for code completion

composer require atoum/stubs

Configuring atoum

Now that it’s installed, let’s perform some preliminary configuration. Specifically, what we’re going to do is to configure how code coverage will reported, as well as what the test reporting will look like when run from the terminal.

This isn’t strictly necessary, but as we may be looking at the test output in the terminal a lot, it helps to give a bit of life to it. Second, whilst the built-in code coverage is pretty good, sometimes viewing it through a browser is just easier to do, as we’ll see in a little while.

If this is your first time hearing about code coverage, code coverage reports the percentage of the codebase which is covered by tests. Code coverage reports help us know how complete our tests are, and how confident we can feel when making changes to the code. So, while there is some work involved in getting code coverage set up, it’s worth having in place.

Continue reading %Testing PHP Code with Atoum – an Alternative to PHPUnit%

Evert PotSyntax highlighting in presentations (19.10.2016, 23:14 UTC)

I often go back and forward between presentations software, trying to find the best one, never being happy. I recently used cleaver, which is nice for simple stuff, but this time I’m back to LibreOffice Impress because I don’t want to spend a long time fighting with layout.

One task that’s never super obvious is figuring out how to do syntax highlighting of code in my presentations. I wanted to share my solution. I’m fairly sure this will also work for MS Office and maybe even Keynote.

First, download Pygments. Pygments is a syntax highlighting tool for the command line.

On ubuntu it can be installed with:

apt-get install python-pygments

If you’re on a Mac, I don’t believe there’s a homebrew package. This should work though:

sudo easy_install Pygments

After that, we’re using the tool to convert your source file into a syntax highlighted RTF file! Yes, the old school format you’d never thought you’d need again.

Run it like this:

pygmentize -O style=xcode -o output.rtf input.js

I picked the xcode style, because it worked fairly well with the light backgrounds in my presentation, but other styles are supported. To see a list run:

pygmentize -L

Instead of pygmentize I also tried highlight, but it was impossible for me to build and seems a bit over engineered.

Using the file

In LibreOffice Impress, just click “Insert” and then “File” to find your rtf file.

Batch syntax highlighting

I don’t want to have to type this every time, so I made this Makefile to automatically do this. The file assumes that you have:

  • A src/ directory containing .js files (you can change the extension).
  • An empty rtf/ directory.

SRC = $(wildcard src/*.js)

RTF = $(patsubst src/%.js, rtf/%.js.rtf, $(SRC))

all: $(RTF)

rtf/%.js.rtf: src/%.js
        pygmentize -O style=$(STYLE) -o $@ $<

        rm rtf/*.rtf

Nomad PHPContaining Chaos with Kubernetes (19.10.2016, 20:47 UTC)

January 2017 - US
Presented By

Terrence Ryan
January 19, 2017
20:00 CST

The post Containing Chaos with Kubernetes appeared first on Nomad PHP.

PHP ClassesHow to Extract Text and Images from PDF File Using PHP (19.10.2016, 16:00 UTC)
By Christian Vigh
Extracting text from individual pages or whole PDF document files in PHP is easy using the PdfToText class.

Read this article that is the first of a series that will teach you about the challenge of processing the PDF file format and how the PdfToText class can be used to extract text and images from it.
PHP: Hypertext PreprocessorPHP 7.1.0 Release Candidate 4 Released (19.10.2016, 00:00 UTC)
The PHP development team announces the immediate availability of PHP 7.1.0 Release Candidate 4. This release is the fourth release candidate for 7.1.0. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system. THIS IS A DEVELOPMENT PREVIEW - DO NOT USE IT IN PRODUCTION! For more information on the 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. For source downloads of PHP 7.1.0 Release Candidate 4 please visit the download page, Windows sources and binaries can be found on The fifth release candidate will be released on the 27th of October. You can also read the full list of planned releases on our wiki. Thank you for helping us make PHP better.
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP