legally superfluous

Hey there!

I'm Martin Jansen and this is my tumblelog. Most cool kids seem to have one these days. Do you?

The things I publish here are replicated on my other home page and there is more stuff there, too.

Posts tagged php

Nov 21

eZ Components Book

Since roughly the end of October, a book by Tobias Schlitt and Kore Nordmann about the eZ Components PHP framework is being shipped. I was honored when Tobias asked me several months ago if I not only wanted to be their technical reviewer but could also write a foreword for them. I’m so glad he asked.

Doing book reviews (I’ve done several before) is first and foremost more work than one might think. Second it is a very fulfilling work because one knows that it results in something that can be seen on shelves in stores and that people actually spend money on. (The same applies for Diet Coke, but let’s ignore this for now.) And finally, seeing ones name listed on page 4 of a book right next to the author(s), the editor and misc. other imprint information makes up a great ego boost. Hope my readers forgive me for this little personality cult …

In addition to this I had a blast writing the two and a half pages long foreword and I’m proud that Tobias and Kore asked me for this. On several occasions during the review process I had problems keeping up with their ambitious schedule because I was busy with other things, and sometimes I felt bad for being so picky about this and that in several chapters. But much to my surprise the authors and their editor Stephan Mattescheck didn’t seem to mind at all about this. Lucky me.

Long story short, if you understand German and want to dive into the world of the eZ Components, I suggest you pick up the book before it’s too late. If German isn’t your lingua franca, don’t give up: I have heard that there may be an English version of the book sooner or later.


Sep 2

Imperfection

Last Friday, Guido van Rossum released the first alpha version of Python 3.0 aka Python 3000. Judging by the changelog, the Python developers got rid of a number of annoyances and inconsistencies in order to make the language more cleaner (again). And prominent Python users don’t seem to be afraid of adjusting their code to work with the new version. Go figure.

Maybe it is time for PHP to jump on this bandwagon as well and start getting rid of historic cruft and inconsistent function naming in some future major release? I’d certainly embrace such a move, because luckily I live in a world where people work in environments controlled by themselves instead of clueless hosting companies, and where my tool-chain supports dependency handling. Thus I couldn’t care less about backwards compatibility that so many PHP developers are afraid of. Luckily the people who do actual work on the PHP engine (which does not include me, FYI) and not the ones who scream loudest are the ones to make such decisions. As a result I expect that we’ll have to live with the current inconsistencies that have made PHP the imperfect yet likable language that it is today.


Apr 28

File upload progress bars with PHP

There is a nifty example by Rasmus Lerdorf about using file upload hooks in PHP 5.2.x to generate a progress bar while uploading a file through a HTML form. The source code is pretty self-explaining regarding all the things that happen on the client side, but unfortunately Rasmus does not mention what is required on the server side to make the magic work.

In order to make it possible for clients to regularly poll a server for the progress of an upload, one needs a bit of middleware that hooks into the right places inside PHP and exports the progress information to “userland” PHP code. In Rasmus’ case, he is using the APC opcode cache to do this. Recent versions of it come with a (yet undocumented) feature which, once enabled, listens for incoming file upload requests that contain a special field called APC_UPLOAD_PROGRESS. If this field is given, APC creates a cache entry named after the value of the field and regularly populates the file upload progress to this entry.

If you look closely at Rasmus’ example, you’ll notice that not only the script uses apc_fetch() in order to read information from a shared memory segment, but also that it includes the magic APC_UPLOAD_PROGRESS field. The value of the field is generated using the uniqid() function so that multiple file uploads happening at the same don’t use the same cache entry.

So how does one trick APC into working that way? The documentation does not say a word about it at the time of writing this, but the installation instructions in the CVS repository tell us that one needs to add apc.rfc1867 = 1 to php.ini in order to enable the hooking. Once you know that, everything works just magically.

Hope this helps.


Apr 20

Services_Yahoo 0.2.0

Some minutes ago I rolled version 0.2.0 of Services_Yahoo, which sports a brand-new fluent interface for the part that implements the web search API. Also the package now uses the serialized PHP data that is provided by Yahoo! instead of parsing their XML output. I’m not yet 100% satisfied with the fluent interface, but I think it comes pretty close to what I want it to be.

It will take until Sunday for the documentation on the PEAR website to be updated, but if you want to try the new release before, you’ll find some example code in the unit tests. Feel free to file a bug report or two if you encounter anything odd.


Mar 23

Candidature

Today I threw my name in the hat for the upcoming PEAR Group election. I have been thinking about whether to run for another legislature or not (I am a member of the current Group) ever since it became apparent that there is interest in the PEAR developers community to form a new organizational structure for the project. In the end I decided in favor of a candidature because I couldn’t come up with a really good reason why I should stop my involvement. A few months ago I would have most likely decided differently for various reasons, but these days the PEAR Threat Level is back to green for me.

Now let’s see what the outcome of the election will be. In any case it will be good for PEAR, which is important. If I don’t get enough votes, there is always CPAN. Or the Cheese Shop. Or raising sheep.