PHP 5.3.99-dev and DTrace Part I

For those not following the PHP development. We backported the DTraces probes from the abandoned PHP 6.0 branch, back to the new trunk PHP 5.3.99-dev. It is called 5.3.99 because the PHP dev community has not decided yet on a version number (5.4 or 6.0).

To compile PHP with DTrace, on Solaris or Mac OS do:

  $ svn co php
  $ cd php
  $ ./buildconf --force
  $ ./configure --enable-dtrace
  $ make

To check if your PHP has DTraces probes enabled, you can check the phpinfo() using

 $ php -i | grep DTrace

or use DTrace directly>

 $ sudo dtrace -ln 'php*:::' -c 'php -m'

88836    php4614               php               dtrace_compile_file compile-file-entry
88837    php4614               php               dtrace_compile_file compile-file-return
88838    php4614               php                        zend_error error
88839    php4614               php  ZEND_CATCH_SPEC_CONST_CV_HANDLER exception-caught
88840    php4614               php     zend_throw_exception_internal exception-thrown
88841    php4614               php           dtrace_execute_internal execute-entry
88842    php4614               php                    dtrace_execute execute-entry
88843    php4614               php           dtrace_execute_internal execute-return
88844    php4614               php                    dtrace_execute execute-return
88845    php4614               php                    dtrace_execute function-entry
88846    php4614               php                    dtrace_execute function-return
88847    php4614               php              php_request_shutdown request-shutdown
88848    php4614               php               php_request_startup request-startup

Have fun with DTrace in PHP.

A few examples will follow in the next days.

Dealing with Sessions in Compojure

I recently started working with Compojure, a web framework for programming language Clojure. After playing around with basic GET and POST requests I tried to store and load data from a session. As Compojure is quiet new, there is not much documentation how to deal with sessions, particularly as Compojure and it’s API still changes fast.

In the following post I’ll show a brief example on how to create a login page with Compojure 0.3.2 running on Clojure 1.1.0.

Continue reading


I really enjoy giving talks. This is particularly because I like to teach people something and because I’m really enthusiastic about the technical things I talk about. Once of these things are obviously decentralized version control system, in particular Git and Mercurial. Finally after two years of submitting talks to various conferences, people and conferences in the PHP community start to pick up this topic. Seems that 2010 is the year of DVCS, and I’m really looking forward to give a talk about the advanced features of Git at

The talk will give a very brief overview how Git works, and will then give a more detailed insight in how Git handles commits, files, etc so that people get a very good understanding about the concepts that are needed to fully understand tools like git rebase, git reflog and git svn. The aim is to provide them will all necessary information and a few examples to get lost commits back, rebase their branches and design more complex git workflows in the future without needing to search the web or ask a guru.

A second talk will be more focused on beginners and developers coming from subversion. This talk will be part of a series of talks the german telekom is organizing. I’ll also give an extended version of this as an in-house workshop at a Munich based company.

So for me it seems that after five years, DVCS is mature enough to get into companies and that we can expect a bright variety of companies to adopt new tools and workflows. Let’s see what’s coming…

For sure I still offer Git and Mercurial trainings, so feel free to contact me (dsp ~at~ php ~dot~ net)

probably shameless self promotion

Clojure, and it’s not a typo.

Why lisp can be sooooo sweet. A clojure class extending java.

compile it

(set! *compile-path* "build")
(compile 'net.experimentalworks.clojure.outdegree)

Ah yeah and hsv2rgb transformation:

Writing a simple PHP sourcecode buildscript in Scala

Scala is a fascinating language. Running on the Java VM, Scala offers a powerful mixture from both the imperative Java world and functional programming including modern techniques like Actors. Personally I prefer to not just learn programming languages, but also try them out while reading through the book.

As I wanted to have nice a build system for my PHP subversion checkout, I used this need as a project to start coding Scala. So what do I exactly need? I want to build multiple versions of PHP from the same branch without checking out the code twice. I also want to configure these builds somewhere without always typing in the parameter list or so. For further versions I want to be able to configure these in a file that can easily be distributed to other machines.

I set down and wrote a parser for a configuration file that can configured build targets which is then build by
the program. The configuration file I used is specialized for this purpose, which is why I didn’t used something like ant or so. The result is called bauaffe-3.0.0a1.jar.

I’ll just show a few things done in the project, but mainly focus on what the nice script can do. Further blog posts will be about the actual implementation.

The configuration looks like this

$ cat ~/.buildmaker
begin default configuration
    define source "/Users/dsp/dev/c/php-src"
    define build "/Users/dsp/dev/c/php-src/build"
    define defaults as
        with "iconv=/opt/local"
    build trunk as
        "php60" using defaults
        "php60-debug" using defaults
            enable "debug"
    build branch "PHP_5_3" as
        "php53" using defaults
            environment PHP_AUTOCONF="autoconf213"
        "php53-debug" using defaults
            enable "debug"
            environment PHP_AUTOCONF="autoconf213"

Proper indention is not necessary (as e.g in python).

You might want to think that parsing the configuration file can be difficult. Well, if you use C you would use YACC, if you use PHP, I don’t know what you would have done, but Scala is made to create this kind of Domain Specific Languages (for my the config is a DSL). You can easily transform a EBNF directly to scala code using the JavaTokenParsers provided by the Scala Library. As an example this it the statement that parses the first line:

def begin : Parser[Configuration] =
"begin" ~ ("default" | stringLiteral) ~ "configuration" ~ rep(define | build) ^^ {
case "begin"~name~"configuration"~confs => new Configuration(name, confs)

which is directly taken from the BNF:

config ::= "begin" ( "default" | string ) "configuration" ( define | build )*

Did I mention that the actual parser is 170 lines of code with usual indention and formatting?

The configuration file is searched in ~/.buildmaker, or if ~/.builmaker doesn’t exists, buildmaker.conf in the current directory. How do you configure the tool? First of all you can specify a configuration. It is usually called “default”. It is not yet supported to name it differently, although the parser is able to parse it. In further versions multiple configurations per file are allowed.

Variables are set using the define syntax. At the moment you can set the build and source variable as well the defaults variable, which is usually a block of statements that can be used in the branch configurations.

A branch is configured using the build syntax. You first have to specify which branch to build. Every branch can then configured to have build target with a given set of options. Branch options are:

  • with string: Builds the target with the given extension
  • enable string: Builds the target with the given extension
  • environment string=string: Builds the target with environment variable

. You can specify using defaults which will cause the runner to use the options specified in the defaults define.

At the moment the parser will not do a good job in notifying you what you are allowed to do and what not, although pure parse error will be emitted. You can also not set any other variable than the described once.


$ java -jar bauaffe-3.0.0a1.jar list
TARGET                         LAST BUILD
php60                          None
php60-debug                    None
php53                          Sat Jan 09 16:55:12 CET 2010
php53-debug                    Sat Jan 09 16:59:37 CET 2010

gives you a list of parsed targets and their last build date. You can build a target using

$ java -jar bauaffe-3.0.0a1.jar 

or build all using

$ java -jar bauaffe-3.0.0a1.jar all

Please notice that the current version requires that you now what you are doing. You might miss some error messages or find them not useful. I’ll change this before the first release, if I’ll do a final version of it. I hope you like the little tool.

Download It!

Scala (pronounced /ˈskɑːlə, ˈskeɪlə/) is a multi-paradigm programming language designed to integrate features of object-oriented programming and functional programming.[1] The name Scala stands for “scalable language”, signifying that it is designed to grow with the demands of its users.

Show exit status of the last executed command in ZSH prompt

We recently stumbled over the problem that we want to know the exit status of the last command that was executed in our ZSH. Well the obvious thing is echoing $?, but as we need this quite often we want to have it in our right prompt. Googling around a little bit, we found the solution:

In your .zshrc add the following line


This will give you the last exit status on the right site of your shell.

My zsh now looks like this (with the additional stuff)

buenosaires:~/dev/c/git.git/>                                         (next)[1]

Writing a hg to subversion gate

Using a decentralized version control system (DVCS) like Mercurial (hg) or Git as a client for Subversion is very common. With the unique features of a DVCS a developer can have both the features of offline development and local branching while still being able to push to a subversion server. This approach is often used in environments in which subversion is the given version control system. While the approach of using this bi-directional push and pull mechanism, provided by git-svn or hgsubversion, works perfectly for one developer, it has limitations working in a team using the usual DVCS push and pull concepts.

The following article will outline the current limitations of bi-directional dvcs to subversion bridges and shows a simple approach to implement a solution for a certain instance of the problem.

Continue reading

Ask a Droid

I bought a G1 dev phone six month ago. Not because I seriously wanted to write applications for the android platform, but because it was the only way to get an Android based phone in Europe. Nevertheless, the complete Android platform is really appealing to me, mainly because it’s more open than an iPhone, there are much more nerdy apps for it and – yeah I know what you think – it’s based on Java.

Warning this is a potential boring blog entry. Apprx writting time was about 5min

I once tried writing applications for the iPhone and started to like the concept of Obj-C while still I hate the syntax and I don’t like the API that much. Android makes things simple for me, and I guess for most people knowing a little bit java. It implements big parts of the Java standard (although it doesn’t claim to be standard compatible) which makes it easy to start writing apps if you know the libraries a little bit. Android also includes the powerful HTTP libraries of the Apache project as well as Json and XML parsers.

Having said this, the most important factor why I started to love my phone and the Android system: I can easily deploy apps on my phone, I debug it on my phone, I have nearly the complete power of the java framework and I totaly enjoy seeing my first app starting on the actual phone after 1 hour of coding. The app itself is fairly simple. It’s a basic search interface phpMyFAQs upcoming Rest API.
So you can search an existing phpMyFAQ installation for a search term and display the result. Although the app needs phpMyFAQ 2.6.0-alpha it’s already available in the Android Market. So feel free to check it out. You can test it with the URL: The source can be found at Expect more updates to the app soon.