PHP Interview With Jakub Vrana Co-Author Of The Official PHP Manual – Learn How To Use Arrays + Use Classes In A Smart Way

About This Interview

This is the #32nd set of PHP Interview to help aspiring PHP developers and PHP fans alike to get inspired by listening from those PHPeople who are already highly involved into the PHP Ocean and *being there* taming the waves and surfing better than ever to make themselves an Awesome PHP Expert both in their own eyes (for self-accomplishment) and for the PHP Community.

On the other side, this is an opportunity for new PHPers to get to know their “PHP Elders. I hope you will derive as much fun to read my interviews as I’m having by interviewing those awesome PHP people.

A Small Intro..

Jakub Vrana – Co-Author Of The Official PHP Manual

In this edition I talked with Jakub Vrana who is a co-author of The Official PHP Manual. @jakubvrana is also the creator of the two successful projects namely Adminer and NotORM. I invite you to know him better and to learn from his 7php PHP interview.

And Now The Interview…

>> Please tell us a bit about yourself

I am the co-author of official PHP Manual, I wrote a book about PHP, I created several open-source projects (Adminer and NotORM being the most successful) and I programmed bunch of websites from the ground up. I’ve spent last year and a half in Facebook working mostly on a code review tool Phabricator.

>> How you started with PHP

I started with Basic on ZX Spectrum, then Pascal in DOS, some C and then I started playing with web. I used mostly Bash scripts at first but then my friend told me: “Try PHP – write it as C, put $ in front of variables and enclose the code in <? ?>.” I did that and it worked on the first attempt. I’ve tried several other languages since then, particularly Python (which I don’t enjoy) and JavaScript (which I like but not that much as PHP).

I chose PHP because it solves my problems without much struggle. Another reason is that being an expert in some language gives you the ability to think solely about the problem and not about the language itself. I also like the simplicity of PHP – nothing should be more complicated than it needs to be. I am with PHP since version 3.

>> The relationship between You and The PHP Community comprises..

I am not very active in the community anymore. I send something to PHP Manual now and then, I occasionally file a bug report.

>> Based on your experience, what are the good and bad parts of PHP

Bad part is inconsistency: strrev() and str_pad(), strpos($big, $small) and ereg($small, $big), imagegif() and mysql_query().

Another bad part is error handling: If everything would just throw an exception, life would be easier – we wouldn’t need the @ operator and handling errors would be overall better. You can write an error handler converting all errors to exceptions but you couldn’t do that everywhere (e.g. in contributing to a third party project).

There were some bad decisions over time which are being nuked or could be nuked in future: magic_quotes_gpc is a terrible approach to escaping, there are three extensions for accessing MySQL, two different regular expression libraries.

PHP started as a templating language but it is actually very poor for templating – you need to manually call htmlspecialchars() everywhere. PDO was supposed to be all you need to access any database but there’s no way to write “IN (:array)”. I see PHP as a quite good low level language good for writing higher level abstractions.

What I love about PHP are data structures – an array is so simple and so powerful at the same time. The object model is sufficient and not so bloated as in other languages.

I also like the variable visibility – global variables are not visible by default inside the functions. When I occasionally read some C code (where it is the opposite) then it’s usually just a mess.

I am also overall happy about the PHP evolution – objects in PHP 4, true objects in PHP 5, namespaces and anonymous functions in PHP 5.3, traits in PHP 5.4 and yield in PHP 5.5. These are all changes making sense as the language evolves.

>> What would be the Top advice to a PHP beginner

Learn how to use arrays. Understand that accessing keys is fast no matter how many elements are in the array (contrary to searching for a value).

>> To someone who wants to become a better PHP developer, what is your advice?

Use classes in a smart way – create small classes with a single responsibility, implement interfaces where appropriate. Learn some framework, templating language and database access library.

>> The best PHP book you’ve read

Shameless plug: 1001 Tips and Tricks about PHP by Jakub Vrana

>> A PHP blog or resource you highly recommend

I’ve enjoyed reading but it’s unfortunately not active anymore.

>> The IDE that you use

I use SciTE which is a simple editor (not IDE) but highly configurable. I’ve implemented some IDE features through this configuration (e.g. jump to a function definition or list all callsites) – the advantage is that it works also in very diverse environments.

>> A PHP framework you use and would recommend

I like and I used Nette Framework. It’s way better than other frameworks in many areas. I am not objective here as I contributed to this project but it’s definitely worth a try.

>> A CMS that you think is worthwhile

I am not a fan of general purpose CMSes. I believe that you should tailor your application and data storage based on your needs and then use a general purpose tool to manage any application and data storage (such as Adminer Editor). The other way around (use general purpose application and data storage) could easily lead to undesirable compromises.

>> Your LAMP stack comprises.. ?

The stack is pretty common in most cases. Sometimes nginx instead of Apache, MySQL backed by Memcache, load balancer or replication here and there.

>> One PHP person that you admire and what strikes you about him/her

I admire Derick Rethans and his approach to solving problems.

Derick Rethans – Father of Xdebug

>> One function that you like

I probably use preg_match() more often than it should be but I just like regular expressions verbosity. preg_match(‘/^abc/’, $s) is way more readable to me than strncmp(‘abc’, $s, 3) === 0.

>> Which was the worst programming mistake you did?

There are two hard problems in computer science – cache invalidation and naming. I often fail in both of them.

>> A unit test framework you recommend using

I don’t like PHPUnit, it’s just too bloated. I like simpler test frameworks, like the one in Nette or in Phabricator. I often wrote my own testing infrastructure (in tens of lines) which allows me to express the tests in more concise and better readable way.

>> Do you recommend using database layers and ORM? If yes, what database “framework” you would recommend?

I don’t like ORMs. Shameless plug again: NotORM is a fresh approach for working with databases – less writing, better performance, simpler code. If it’s still too high level for you then use something lower level like Dibi or qsprintf(). Don’t use raw PHP libraries (including PDO) as it’s very hard to secure the queries against SQLi with them.

>> What is the one thing that you wish PHP had?

I wished for a long time that PHP would have anonymous functions. It now has them (including $this after some struggle). I wished PHP has ‘yield‘ which is very useful with extreme PHP applications (like Facebook). It’s in PHP 5.5. I sometimes wish that PHP has scalar type hints (but it’s contentious) and return type hints (which would be great for designing APIs).

>> Could you tell us a bit how a PHP developer can test and measure the Performance of his PHP code?

There are some great extensions like XHProf to profile performance. I often use microtime() around a code block for simple one-offs. But the most important part is usually elsewhere – it’s in realizing how the algorithm behaves in means of asymptotic complexity. If it’s O(N^2) and we operate on 1 million objects then it doesn’t matter if we squeeze the time of one operation from 0.002 seconds to 0.001. Much better is to implement an O(N) algorithm (if possible) and then start worrying about the single operation performance.

If we wait for 1000 slow requests (e.g. HTTP or DB) then the point is not in squeezing the wait time from 0.5 seconds to 0.4 but in waiting on all these requests in parallel or squeezing them to one bigger request. Revolution (rethinking how it should work) is often simpler than evolution (trying to optimize the current approach) if you want to hit the same target.

Jakub Vrana & PHP Documentation

>> Could you tell us a bit how the process of writing and submit goes? Is there any kind of peer review or discussion..etc?

Most changes are just “write and commit”. There’s some post-commit review with questionable changes in the mailing list and there’s some pre-commit discussion with structural or other major changes. But most of the time, it’s just a self-review.

>> What are the challenges that may exist

Contributing to PHP Manual is surprisingly simple. The biggest deal is building reputation – making some meaningful changes (e.g. in the form of patches to bug reports) before you get a commit access. The DocBook format is easy to read and write.

>> How are the ‘author-ship’ decided?

It’s decided every couple of years based on past and recent contributions.

>> Can anyone apply to be part of it? How does it work?

Yes, anybody can contribute. There’s an Edit link on every manual page (linking to where you can start. For bigger contributions, I suggest checking out the sources from

Closing Out With Jakub..

>> You are the author of the book “1001 tips and tricks for PHP”. Out of those 1001 tricks/tips could you highlight your best 3 (or 5) for my readers?

I don’t really have a list of the best tips. These are some random tips I hit by skimming through the book:

  • Why don’t use the Referer header for the CSRF protection.
  • When do you want to call ob_flush() and flush().
  • How to decide between ‘decimal‘ and ‘real‘ database types.

>> Things that you’ve learned from being part of The PHP Community

I’ve learned that amount and quality of work matters. If you send lots of meaningful contributions and you improve the code then your voice is more powerful than if you just sit and talk.

>> If you could change one thing with PHP, that would be…?

magic_quotes_gpc made such a mess and discredited PHP on many levels. I would be happier if it never wouldn’t be a part of PHP. And yes, I’ve used this feature extensively in the past too.

>> The day you realized “You’ve made it to the A-List PHP arena” ?

For me, the A-List are the contributors to the PHP language (mostly C programmers). The B-List are the main contributors to frameworks and widely used PHP applications. I might be in a C-List. I probably made it there just by writing about what I am doing on my blog and by publishing my work in the means of open-source.

>> Why you are successful and why others are not?

I want to believe that I’m successful because I’m not lazy to think but I’m lazy to manually work. I’ve mentioned it in the revolution versus evolution approach to the performance. I experience it in the code reviews I’m doing a lot recently – it’s very easy to read the code line by line and say that it’s “correct”. A much more challenging approach is to take a step back, think about the problem that the code is trying to solve and answer yourself a question if this is the right approach.

Being lazy to manually work means that I rather discover a better abstraction than copy/paste a code and modify it on thousand places later.

>> You are involved a whole lot in your PHP endeavours. How do you time manage all that – how do you coordinate everything and balancing all that with your personal life?

I usually do what I like the most and I believe that’s the receipt for a happy life. Do what you are best in and what you like the most, become even better in it and someone will eventually value it.

>> A final word before closing up..

Try to always work on something that you also personally use. It makes a huge difference if someone just gives you instructions what to build or if you actually feel it by using it. I believe that this is the key factor in successful products and also in happiness of people building this product.


Now Do Your Part!

1) LIKE 7PHP dot COM on FaceBook – if you appreciate what I do

2) Help diffuse this interview to the PHP ecosystem – Share, tweet and spread the word to your audience ==> That would be a FREE way to thank me 😉

3) Make a comment below using the comment form – I’m sure you can at least say 1 word about this interview

{I’m thankful to your response(s)!}

4 Comment(s)

  1. Great interview!
    For me Adminer is the best web db management tool (a lot better and simpler than phpMyAdmin) and it was very interesting for me to read an interview with it’s author.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.