Christians Tagebuch PHP_CodeSniffer + emacs 24: Compilation error (6.5.2013, 08:25)

After ugprading to Ubuntu 13.04, emacs did not highlight compilation results from PHP_CodeSniffer anymore. Instead of a nicely colored log window, had the following in the *Messages* buffer:

Warning: defvar ignored because compilation-error-regexp-alist is let-bound
(No files need saving)
Error during redisplay: (void-variable compilation-error-regexp-alist) [4 times]
Compilation exited abnormally with code 1

A bug report gave me the hint about what to change:

To have the compilation mode variables globally available, I need to require the module in global scope, not in the scope of my phpcs-compilation definition.

So after adding (require 'compile) before (defun phpcs() .. in my .emacs file, compilation works properly again.

PHP_CodeSniffer 1.4.5 and 1.5.0RC2 released (3.4.2013, 22:55)

PHP_CodeSniffer versions 1.4.5 and 1.5.0RC2 have just been uploaded to PEAR and are now available to install. Version 1.4.5 is primarily a bug fix release although there are a few new sniffs and sniff settings that some developers may find useful. In addition to these changes 1.5.0RC2 contains big...

Christians Tagebuch PEAR: Search packages in all channels using Pyrus (8.2.2013, 17:02)

Our old and trusted PEAR Installer supports multiple package sources, called "channels", since version 1.4.0 - which was released in 2005. You can host a channel yourself using one of the channel server applications. The most popular one is probably Pirum.

One of the problems with such a distributed network is finding the channel that provides the package you are looking for.

Pyrus, the PHP 5.3+ PEAR installer, has a solution for that:

$ pyrus search mockery
Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52
Using PEAR installation found at /opt/phpfarm/inst/php-5.3.16/pear
Searching for mockery
1 packages found:

$ pyrus install
Pyrus version 2.0.0a4 SHA-1: 72271D92C3AA1FA96DF9606CD538868544609A52
Using PEAR installation found at /opt/phpfarm/inst/php-5.3.16/pear
Sorry, the channel "" is unknown.
Do you want to add this channel and continue?

Please choose: 
[yes] : 
Discovery of channel successful

Pyrus is able to search all existing channel servers and automatically discover then when they are not known yet.

Technical background

When running pyrus search, it asks the online service This service checks for package releases on the channel servers every night and indexes them.

The list of channel servers that uses is fetched from , which is an export of our PEAR channel server list.

So if you want Pyrus to find the packages of your PEAR channel, register your channel on this list.

PHP_CodeSniffer 1.4.4 released (6.2.2013, 23:28)

PHP_CodeSniffer version 1.4.4 has just been uploaded to PEAR and is now available to install. This is primarily a bug fix release although there are a couple of nice new sniff features that some developers may find useful including a new sniff to run CSS Lint on your CSS...

PHP_CodeSniffer 1.4.3 released (4.12.2012, 03:27)

PHP_CodeSniffer version 1.4.3 has just been uploaded to PEAR and is now available to install. This is primarily a bug fix release although support for the upcoming PHP 5.5 T_FINALLY token has been added a few PSR-2 issues have been fixed and a change has been made to improve...

PHP_CodeSniffer general memory improvements (15.11.2012, 04:38)

PHP_CodeSniffer version 1.3.6 introduced memory improvements when using the summary report. You can take a look at the improvements that were reported at the time when running over the Symfony2 codebase. Obviously the summary report is only useful when running PHP_CodeSniffer from the command line and viewing the output...

PHP_CodeSniffer 1.4.1 released (1.11.2012, 23:43)

PHP_CodeSniffer version 1.4.1 has just been uploaded to PEAR and is now available to install. This release includes a few important changes for developers who maintain their own standards and sniffs. Ignore Patterns In version 1.3.6 ignore patterns were changed so that they are checked against the relative path...

PHP_CodeSniffer 1.4.0 released (26.9.2012, 04:42)

PHP_CodeSniffer version 1.4.0 has just been uploaded to PEAR and is now available to install. This release includes two new coding standards; PSR-1 and PSR-2.A lot of effort has gone into compiling these standards from existing sniffs writing new sniffs and making core changes to PHP_CodeSniffer to support new...

Christians Tagebuch Surrogator - free avatar image server (17.8.2012, 22:02)

Avatar for cweiske I hereby announce the release of Surrogator version 0.1.0, a simple Libravatar compatible avatar image server written in PHP.


You probably know Gravatar, the (proprietary) service by the guys. You give it the md5 hash of an email address and get an image for it - given that the person owning the email address registered there and uploaded a picture.

Many many blog and web applications use those images to give comments a personal note and make it easy to recognize the commenters.

Libravatar (libre avatar) does basically the same, but has some huge benefits:

  • It is federated, which means that you can host your own avatar server for your domains. In case or Gravatar are down, images for your email addresses will still be delivered.
  • You can use it as a service like Gravatar if you don't want to host your own server. But unlike Gravatar - which you cannot leave - you have full control over your avatars and your account. Full account export and removal are supported.
  • You can assign images to OpenIDs.
  • It is open source. The Libravatar sources are open for anyone to inspect, improve and install on your own server.
  • It falls back to Gravatar. The userbase of Gravatar is not to be neglected, so Libravatar falls back to the Gravatar image if there is no Libravatar one.
  • You do not have to register another account but may login with your OpenID.


The original Libravatar software is written in Python and contains the whole package: Profiles, login, image upload, email and OpenID management.

I do not need all that; all I want is to put an image file somewhere, and that's it. This is Surrogator.

Just download (or git clone) Surrogator, follow the 4 setup steps, put the image files in the raw/ directory and that's it. It just works and takes little server resources.


So Libravatar is cool, how can you use it? Luckily, Melissa Draper wrote the Services_Libravatar library which is documented and easily installable via PEAR or Pyrus:

$ pear install services_libravatar-alpha

Using it is as easy as writing four lines of code:

echo 'Avatar';

That's it. Now start using free avatar images in your software, and use one of the available plugins.

Christians Tagebuch PHP_CodeSniffer: notify-send report (14.8.2012, 16:22)

I use emacs as IDE, and wanted to have direct feedback about the validity of my .php files when writing them. The most easy way was to add a save hook that runs PHP_CodeSniffer - but the results should be displayed in a nice, unobtrusive way.

phpcs has multiple reporting modes - xml, checkstyle, csv etc. - but nothing for the desktop. I thought that notify-send would be the right fit since it is able to display pretty popup messages without getting in the way.

So I hacked a bit and send a pull request to Greg that got merged today. So in the next version of PHP_CodeSniffer, you will be able to enjoy it, too!

So when running

$ phpcs --report=notifysend file.php

you will see something along this:

phpcs error phpcs ok

emacs integration

The integration into emacs is pretty simple. Just put the following into your .emacs file:

(defun phpcs-notifysend()
  "Performs a PHP code sniffer check on the current file and shows a
popup message." (interactive)
   "phpcs" nil
   (format "phpcs --standard=TYPO3 --report=notifysend \"%s\""

Using M-x phpcs-notifysend, you'll run the check immediately. Running it automatically when a file gets saved isn't hard either:

(defun phpcs-notifysend-hook ()
  (when (string-match "\.php$" buffer-file-truename)
(add-hook 'after-save-hook 'phpcs-notifysend-hook)


Hans-Peter Buniat told me about his tool Testy which runs unit tests and has many options to notify you about the results - including notify-send, dbus and Growl. It could be started from within emacs, too.

Links RSS 0.92   RDF 1.
Atom Feed  
PHP5 powered   PEAR
Link the Planet <a href="">Planet PEAR</a>