Subscribe: Planet PHP
Preview: Planet PHP

Planet PHP

People blogging about PHP


ZendCon 2016 - Stefan Koopmanschap

Fri, 21 Oct 2016 03:30:00 +0000

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.

Incorporating Custom PHP Code in Fabrik Website Applications - Nomad PHP

Thu, 20 Oct 2016 17:21:19 +0000

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.

Testing PHP Code with Atoum – an Alternative to PHPUnit - SitePoint PHP

Thu, 20 Oct 2016 17:00:39 +0000

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!


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.


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%

Syntax highlighting in presentations - Evert Pot

Wed, 19 Oct 2016 23:14:17 +0000

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

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 files (you can change the extension).
  • An empty rtf/ directory.

SRC = $(wildcard src/*)

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

all: $(RTF)

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

	rm rtf/*.rtf


Containing Chaos with Kubernetes - Nomad PHP

Wed, 19 Oct 2016 20:47:29 +0000

January 2017 - US
Presented By

Terrence Ryan
January 19, 2017
20:00 CST

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

How to Extract Text and Images from PDF File Using PHP - PHP Classes

Wed, 19 Oct 2016 16:00:08 +0000

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 7.1.0 Release Candidate 4 Released - PHP: Hypertext Preprocessor

Wed, 19 Oct 2016 00:00:00 +0000

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.

Modding Minecraft with PHP – Buildings from Code! - SitePoint PHP

Tue, 18 Oct 2016 21:00:59 +0000

I’ve always wanted to make a Minecraft mod. Sadly, I was never very fond of re-learning Java, and that always seemed to be a requirement. Until recently. Thanks to dogged persistence, I’ve actually discovered a way to make Minecraft mods, without really knowing Java. There are a few tricks and caveats that will let us […]

Continue reading %Modding Minecraft with PHP – Buildings from Code!%

Importing and aliasing PHP functions - Simon Holywell

Tue, 18 Oct 2016 14:50:26 +0000

As a follow on to my short post about namespaces and functions from a year ago I thought it would be worth covering importing a specific function and aliasing functions via namespace operators too. This has been possible since PHP 5.6, but there is a nice addition in PHP 7 I’ll cover towards the end. In the previous article I demonstrated how you can namespace functions and use them, but as a refresher; you can enclose functions within a namespace just like a class. In the following example there is a function setup in the MyProject\MyModule namespace first, which is subsequently called by code inside the root namespace (namespace { }). namespace MyProject\MyModule { function get_nice_superlative_for_me_please() { return 'gorgeous'; } } namespace { use MyProject\MyModule as M; echo "You're " . M\get_nice_superlative_for_me_please() . ' today'; // You're gorgeous today } Hopefully this is all pretty straight forward and clear to follow. Now onto the use keyword and how it can be implemented to import a specific function. namespace MyProject\MyModule { function get_nice_superlative_for_me_please() { return 'gorgeous'; } } namespace { use function MyProject\MyModule\get_nice_superlative_for_me_please; echo "You're " . get_nice_superlative_for_me_please() . ' today'; // You're gorgeous today } Note the use function construct here instead of the usual straight forward use that you’d normally see when importing a PHP namespace. This imports just the specified function for use in the current scope. So, my example function name sure is a little ungainly and a bit of a chore to type with it’s long name. For the sake of demonstration let’s assume that we can’t change the function name, but we still want it to be shorter in our current scope. To do this we can use the familiar as keyword used in namespace aliasing. namespace MyProject\MyModule { function get_nice_superlative_for_me_please() { return 'gorgeous'; } } namespace { use function MyProject\MyModule\get_nice_superlative_for_me_please as compliment; echo "You're " . compliment() . ' today'; // You're gorgeous today } As we did earlier we’ve gone with use function to show that we’re importing and later aliasing a particular function. This is also works for functions in the root or same namespace as each other. use function get_nice_superlative_for_me_please as compliment; function get_nice_superlative_for_me_please() { return 'gorgeous'; } echo "You're " . compliment() . ' today'; // You're gorgeous today Now if you’re running PHP 7 you can do a another little trick with the namespace operators. If you want to include multiple specific functions in the current scope you can use the new braced grouping syntax. namespace MyProject\MyModule { function get_nice_superlative_for_me_please() { return 'gorgeous'; } function verb() { return 'looking'; } function when() { return 'today'; } } namespace { use function MyProject\MyModule\{verb,when}; use function MyProject\MyModule\get_nice_superlative_for_me_please as compliment; echo "You're " . verb() . ' ' . compliment() . ' ' . when(); // You're looking gorgeous today } Here you can see group syntax ({verb,when}) and function aliasing that we saw earlier working together to create the expected text output. Unfortunately, you cannot alias and group import in the one hit as you would generate a parse error (syntax error, unexpected 'as' (T_AS), expecting ';') with code like the following example: namespace MyProject\MyModule { function get_nice_superlative_for_me_please() { return 'gorgeous'; } function when() { return 'today'; } function verb() { return 'looking'; } } namespace { [...]

Interview with Michael Heap - Voices of the ElePHPant

Tue, 18 Oct 2016 10:00:40 +0000


width="560" height="315" src="" frameborder="0" allowfullscreen>

Audio only

The post Interview with Michael Heap appeared first on Voices of the ElePHPant.