SitePoint PHPFinding Differences in Images with PHP (25.5.2016, 16:00 UTC)

I recently stumbled across a fascinating question: how could I tell whether an image had changed significantly? As PHP developers, the most troublesome image problem we have to deal with is how to resize an upload with an acceptable loss of quality.

Two similar images with hidden differences

In the end I discovered what many before me have - that this problem becomes relatively simple given the application of some fundamental mathematical principles. Come along with me as we learn about them...

You can find the code for this tutorial at


There are two popular ways of thinking about images. The first is as a grid of individual pixels, composed of varying levels of color and contrast. Commonly, we break these colors down into their constituent red, green, and blue values. We could also think of them as hue, saturation, and lightness.

The second way of thinking about images is in terms of vectors. A line isn't the pixels in between but rather a starting point and an ending point, with some meta data that describes a stroke in between. We're going to focus on bitmaps because they'll make the whole process easier.

We can break any image down into this bitmap grid, with code resembling:

$image = imagecreatefrompng($path);
$width = imagesx($image);
$height = imagesy($image);

$map = [];

for ($y = 0; $y < $height; $y++) {
    $map[$y] = [];

    for ($x = 0; $x < $width; $x++) {
        $color = imagecolorat($image, $x, $y);

        $map[$y][$x] = [
            "r" => ($color >> 16) & 0xFF,
            "g" => ($color >> 8) & 0xFF,
            "b" => $color & 0xFF

Given the width and height of the image, we can use a function called imagecolorat (on an image resource) to get a single integer value for the red, green, and blue at that pixel. We can then use bit shifting and masking to get the individual values of each from the single integer value.

Continue reading %Finding Differences in Images with PHP%

Nomad PHPSymfony Console Component (25.5.2016, 15:06 UTC)

Speaker: Juan Manuel Torres @onema Did you know that PHP can be used to create Command Line Interface (CLI) applications? In fact, CLI support was officially added in version 4.3.0 more than 13 years ago! This talk will guide you through the basics steps to create, configure, run, and test your own CLI application using …

The post Symfony Console Component appeared first on Nomad PHP.

Brandon SavageWhy I write, maintain and use my own framework (and you should too) (25.5.2016, 12:00 UTC)

Note: The recommendations in this post are intended for a very advanced audience. While the content applies broadly, creating and maintaining your own framework is not advised for everyone, unless you know exactly what you’re doing. For many of us in the PHP community, our identities are as much tied into the framework we use […]

The post Why I write, maintain and use my own framework (and you should too) appeared first on

PHP ClassesPHP and JavaScript Innovation Award Report May 2016 Edition - February 2016 nominees (25.5.2016, 04:33 UTC)
By Manuel Lemos
This is the May edition of the Innovation Award podcast hangout recorded by Manuel Lemos and Arturs Sosins to comment on the outstanding features of all the past month nominees and winners PHP and JavaScript packages, the prizes that the authors earned, starting with the nominees from the month of February 2016.

Listen to the podcast, or watch the hangout video to learn why the nominated packages were considered to be innovative, as well the current rankings of the Innovation Award Championship by author and by country.
SitePoint PHPPlease: Automated CMS and Framework Installs in Vagrant (24.5.2016, 22:00 UTC)

If you're a web developer, possibly one of your most boring and repetitive tasks is the configuration of the basic setup for every new project. Configuring your domain, creating the database, installing WordPress (or any other CMS/Framework) for the thousandth time: you already know how to do it. What if you could automate all of that?

Well, actually, you can.

Please is a simple bash script that helps to automate the installations of many CMSs and Frameworks by configuring them automatically into your Vagrant box, adding a development domain name into your host file, and even a database if needed.

Let's take a look.

Important Notice

Since Please is still in beta version (0.3), I suggest that you not use it immediately in your production, but to test it first --- to make sure everything works as you require. There's no risk about losing data and so on --- the worst thing that could happen is that it's not working --- but it's always better to be safe.


So, first, you need to setup a Vagrant box.

If you're new to Vagrant, I suggest you read this nice introduction to understand the whole thing and get started the right way.

A small Vagrant box (a fork of has been created for this project, and it's named Please Box.

Here are all the steps for installation:

$ git clone please-box
$ cd please-box
$ vagrant up

Please also requires the Vagrant HostsUpdater plugin to get everything to work. The installation is quite simple; here's the command to save you some time:

$ vagrant plugin install vagrant-hostsupdater

That's it, you're all set to start using Please!

Install Please

There are very few steps needed to install Please, as written in the official documentation:

$ git clone
$ sudo chmod +x please/please
$ sudo mv please/please /usr/local/bin/please && sudo rm -R please

The && sudo rm -R please part is only to keep your computer clean; since the git clone part clones the full folder of the repo, including the README file, you may not want to keep these on your computer.

Continue reading %Please: Automated CMS and Framework Installs in Vagrant%

Christian WeiskeTYPO3: Oops, an error occurred! (24.5.2016, 17:43 UTC)

On your TYPO3 production machine (TYPO3_CONTEXT=Production) an extbase plugin crashes and only leaves a cryptic message:

Oops, an error occurred! Code: 201605240939366c16aa1f

If you did not modify TYPO3's error handling , the real error message is logged by TYPO3\CMS\Core\Log\Writer\FileWriter into typo3temp/logs/typo3_*.log.

This does of course not help if you don't have SSH access to the live server. The exceptions also do not follow normal error flow - which means a docker logs -f does not show it, and they will also not show up on your log server.

To fix this, overwrite the default configuration in typo3conf/AdditionalConfiguration.php:

// configure default logger to log to nginx error log
// so that we'll see this in graylog
     'writerConfiguration' => [
         \TYPO3\CMS\Core\Log\LogLevel::WARNING => [
             \TYPO3\CMS\Core\Log\Writer\PhpErrorLogWriter::class => []

Do not try to put this into typo3conf/LocalConfiguration.php; TYPO3 will merge it with the default config, leaving you with both FileWriter and PhpErrorLogWriter. TYPO3's default configuration is defined in typo3/sysext/core/Configuration/DefaultConfiguration.php.

Nomad PHPMake Your Code Do Your Job (24.5.2016, 14:56 UTC)

August - EU
Presented By

Larry Garfield
August 18, 2016
20:00 CEST

The post Make Your Code Do Your Job appeared first on Nomad PHP.

Rob AllenView header and body with curl (24.5.2016, 12:13 UTC)

I recently discovered the -i switch to curl! I have no idea why I didn't know about this before…

Curl is one of those tools that every developer should know. It's universal and tends to be available everywhere.

When developing APIs, I prefer to use curl to view the output of a request like this:

$ curl -v -H "Accept: application/json"
*   Trying
* Connected to ( port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* Server certificate: Gandi Standard SSL CA 2
* Server certificate: USERTrust RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET / HTTP/1.1
> Host:
> User-Agent: curl/7.43.0
> Accept: application/json
< HTTP/1.1 200 OK
< Date: Sun, 15 May 2016 11:05:27 GMT
< Server: Apache
< X-Powered-By: PHP/5.6.4
< Access-Control-Allow-Origin: *
< Content-Length: 363
< Content-Type: application/json; charset=utf8
* Connection #0 to host left intact

-v is for verbose and so you get told all the information you could possibly want. However, usually, I only want to know the response's headers and body.

Enter the -i switch!

$ curl -i -H "Accept: application/json"
HTTP/1.1 200 OK
Date: Sun, 15 May 2016 11:10:24 GMT
Server: Apache
X-Powered-By: PHP/5.6.4
Access-Control-Allow-Origin: *
Content-Length: 363
Content-Type: application/json; charset=utf8


Much better!

-i is for include and from the man page:

Include the HTTP-header in the output. The HTTP-header includes things like server-name, date ofthe document, HTTP-version and more…

This is exactly what I want without the information that I don't!

PHP ClassesInstalling a Database Schema from a JSON format (24.5.2016, 04:37 UTC)
By Samuel Adeshina
Installing a database schema is an important setup task that most PHP applications need to do.

The Scripd package can generate the necessary SQL to install all types of database structures that you may need from the database itself, tables, fields, indexes, stored procedures, views, etc., all from a database independent format based on JSON.

Read this article to learn how to use the Scripd package to generate database independent SQL to install your database schema.
Voices of the ElePHPantInterview with Beau Simensen (24.5.2016, 04:01 UTC) Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP