PHP Interview With Davey Shafik The Original Author Of PHAR (The PHP Archive) – The Best Thing About PHP Is The Community

Contents At Glance

Purpose Of This Interview

This is the #14th set of PHP Interview to help aspiring PHP developers and PHP fans alike to get inspired by listening from those PHP guys 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 A-List PHP guys.

A Small Intro..

Davey Shafik – Author of PHAR

In this edition I talked with Davey Shafik (@dshafik), who is one of the Founding Contributor of PHP Zend Framework. He has been a co-author of several prominent books, namely: php|architect’s PHP 5 Zend Certification Study Guide, PHP Master: Write Cutting Edge Code, The PHP Anthology: 101 Essential Tips, Tricks & Hacks. He is also a well-known speaker at several world-wide PHP Conferences – You can find his incoming conference schedules on his website.

And Now The Interview…

>> Please tell us a bit about yourself

I’ve been a developer for about 12 years; it took me through college, and across the Atlantic from England, to Florida, where I live with my wife and cats. I like photography, good drama TV and anything geeky.

>> How you started with PHP

When I was 16 I had a South Park fan site, and I wanted to make it dynamic; I saw that a friend with a popular Simpson’s site had done this and he told me about PHP. My first script? Renaming my index.html to index.php — the fact it still showed up amazed me.

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

Image by DigitalArt

I love the PHP community; I consider our community the biggest asset of the language (I wrote about it here: Making the case for PHP) and is really the key differentiator when it comes to pitting it against other languages like Ruby or Python.

As far as my contributions to the community, probably the largest one is the concept of PHP Archives (phar); which thanks to Greg Beaver and Marcus Börger was moved to a C extension and included in PHP 5.3 by default.

Besides that, I’d like to think that I am a good voice for most every day professional developers when it comes to how to use the language and how to shape the future of the language.

>> How do you find PHP now as compared to when you first started

I started using PHP with 4.0.6; before we even had super globals. The changes to the language (better object model, closures, namespaces) are really not where the biggest changes have occurred however; as a community we have matured and grown. We power the biggest and brightest of the Internet and as a community we enable folks from Facebook down to a sole developer to write mature, successful code.

>> Some of the exciting parts of the new PHP 5.4 are…

I was mostly excited about traits, but the new changes to closures are pretty excited as is the performance increases. The built-in CLI server is also pretty cool.

>> The parts of PHP which kinda fascinates you and why?

I love the streams layer; it’s a great system for handling I/O and the extensibility is phenomenal. I love that you can write custom I/O layers with sane interfaces, in user-land PHP code, and have it just work.

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

Image by jscreationzs

As I’ve said, the best thing about PHP is the community; it can also be the worst thing — a few bad seeds can ruin some things. As far as the language, the best part is that most everything is built in (maybe not enabled by default). I hate to say this, but I don’t have a worst part about the language — the worst parts are simply the things it wasn’t made for; long running processes, multi-threading and such. When you encounter the wrong parts, you’re typically using the wrong tool.

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

Find an itch you want to scratch. Writing code just to see it run is boring, solving a problem has infinitely more rewarding feedback, and you’ll feel like you’re progressing much faster.

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

Photo by zirconicusso

Learn your tools; PHP is so much more than the language, there is an entire eco-system we have to work with. Learn to ask questions, and where to ask questions; and to take criticism in response to them.

If I had to give you a check list of things you should at least know about:

  • Revision control (my preference is git)
  • Data modelling and apply it to both a relational DB (my preference is MySQL, PostgreSQL is also awesome) and a NoSQL DB (mostly I work with Mongo, but check out CouchDB)
  • Key-value stores (memcache, membase, redis)
  • Background processing (gearmand)

>> Some performance advice and optimisation tips..

Always, always profile your code before you make changes; never assume bottlenecks. I love xhprof (with Paul Reinheimer’s xhprof gui) and xdebug. Also, learn your database, it’s probably the number one cause of slowdowns, and often a fairly trivial one to fix. {@preinheimer}

>> The best PHP book you’ve read

Photo by David Castillo Dominici

I have two, but both are aging at this point:- George Schlossnagle’s Advanced PHP Programming, and the 2nd is Sara Golemon’s Extending and Embedding PHP. Another great book is Chris Shiflett’s Essential PHP Security. If you don’t mind going outside of PHP, then Steve Krug’s Don’t Make Me Think is a great book on user experience. {@g_schlossnagle, @SaraMG, @shiflett, @skrug}

>> A PHP blog or resource you highly recommend

There are several, for PHP news, phpdeveloper.org, for conferences, Joind.in, and for helping you get work done, the obvious, php.net/manual. {@phpdeveloper, @joindin}

>> The IDE that you use

After a long love affair with Zend Studio (till it switched to Eclipse) I am now using Netbeans with great success.

>> How do you debug your PHP code?

Depending on the situation, sometimes it’s strategically placed var_dump()‘s, other times I pull out the Netbean/xdebug debugger and work through it.

>> A PHP framework you use and would recommend

Find one that clicks for you, and that you enjoy working with. I personally have the most experience with Zend Framework, but it’s not for everyone. {@zfChannel}

>> A unit test framework you recommend

Nothing beats PHPUnit thanks to the tireless work of Sebastian Bergmann {@s_bergmann}

>> Your LAMP stack comprises.. ?

For an OS, I use Ubuntu/Debian or Gentoo. My personal web server of choice is Apache, but I also use Nginx daily. I’m a MySQL user and frequently preach about it! While I mostly work in PHP, I’m starting to use (and love) Python on a regular basis; it is a great complimentary language.

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

Photo by Graur Razvan

This is a really tough question; I think I would have to pick Sebastian Bergmann: his commitment to quality is second-to-none. I know I can trust most any code crafted by him implicitly. {@s_bergmann}

>> One function that you like (or which you tend to use frequently)

I love the date time extension as a whole; learn it if you’re ever doing anything with dates and times.

>> One PHP Community that you recommend

The FRAPI community {@getFRAPI}; we’re very small but growing, with smart folks and good ideas. #frapi on freenode IRC, or http://github.com/frapi/frapi

>> Which was the worst programming mistake you did?

Not programming, but I once restored *every* client database (250 or so) back 20 minutes instead of just a single client. Whoops. There was also the time I accidentally created and called an anonymous function some 600,000 times using several GB of memory in a long running process. Oh, and I can’t forget the overzealous garbage collection that slowed down another long running process from minutes to hours (and then we removed the reason for the garbage collection but left it in… till we realized our mistake!). Everybody makes mistakes; the key is to identify them (profiling is great for this!), fix them, and learn from them.

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

Personally I use PDO straight up. No generic solution can understand my data structures as well as I can, nor write better SQL for anything beyond simple CRUD.

Davey Shafik & Cerebral Cortex

>> You were also the man behind the PHP framework Cerebral Cortex back in 2003

>>>> could you tell us the motivation behind creating it and why it was unfortunately not sustained..

I created it because I needed it; scratched an itch. I abandoned it to work on Zend Framework‘s initial release which at the time seemed to be doing most of what I needed and had a great driving force behind it.

>>>> What you learned through this journey

Documentation is everything. Document ideas, reasoning and end results.

>>>> The mistakes that you did (which we can learn from)

XSLT is a terrible terrible technology. Great in concept, but such a horrible thing to work with!

>>>> The best parts of Cerebral and which you think other frameworks lack as compared to it..

Cerebral Cortex was built around the idea of separation of concerns; and agnostic interfaces — I don’t see why we should not be able to make at least a large subset of our internal APIs accessible via web services. Ideally, I would be able to write back-end code; then expose
if via an API+Ajax to my front-end, and allow anyone else who wants to use the same APIs.

>>>> any existing framework to which Cerebral might be a subset?

As I mention, I went to work on Zend Framework, so a lot of my ideas came with me; especially the web services stuff.

Davey Shafik & PHAR

>> You are also the Original author of PHAR:-

Image by DigitalArt

>>>> Tell us a bit about it

PHAR came about after looking at Java’s JAR format. The very first version of PHAR came about with me hacking around using the `tar` command to archive PHP files with specially crafted filenames. Once I realized PHP could indeed work with this, I wrote the initial implementation using PHP‘s streams layer in user land, and as I said earlier, others took that, re-wrote it in C, made it more awesome and got it into PHP 5.3.

>>>> What does it try to solve/achieve

The ability to package everything for an application into a single distributable file is a great thing.

>>>> Instances when you use PHAR in your day-to-day PHP life..

I really don’t; I don’t ship many whole products (like say, phpBB or Drupal). I solved a problem that I didn’t have!

>>>> What is it’s current status and any future plans for it?

I don’t really think there is much more to do with it; better interaction with byte code caches would likely be the next step, but my C-fu isn’t up to that task. Any volunteers?

Davey Shafik & PEAR

>> As a long-time PEAR contributor :-

>>>> Tells us a bit about PEAR and what does it try to achieve..

PEAR is the original, PHP Group sanctioned userland components project. It’s goal was to provide simple, re-usable components that were best-of-breed. With peer review and other such good things.

>>>> ‘Some voices around the web complains about PEAR not being relevant anymore..etc’ – What is your view on that?

I mostly agree with the view on PEAR‘s packages, but I still believe that as a package manager it is a great solution. The PEAR channels concept is great.

>>>> Any other PEAR alternative?

There is composer {@packagist}, but I’m not a big fan simply because I believe PEAR is still the best solution for the problem.

>>>> With the advent of solid frameworks, do you still think PEAR is useful

Again, if you separate the packages from the package manager, it’s a great tool, and a number of frameworks are available via PEAR channels, as well as other projects like PHPUnit.

Closing Out With Davey

26) The day you realised “You’ve made it to the A-List PHP arena” ?

Probably at php|tek 2008 – @phptek (I think) when someone said “Wait, you’re *the* Davey Shafik?“.

27) Why you are successful and why others are not?

Wow, that’s a tough question; I eat, sleep and breathe this stuff. It has never been a “job”. I genuinely enjoy learning about the tech ecosystem we are part of, and I think keeping on top of things makes my skills competitive.

28) A final word before closing up..

Image by PhotoStock

If you can, get yourself to a community event; either a user group, or a conference – it is simply the best way to grow as a developer. I’ll be at php|tek (in Chicago), The Dutch PHP Conference (DPC, in Amsterdam) and Lonestar PHP (Dallas, Texas), if you make it to any of them, come and say hello! {@phptek, @dpcon, @lonestarphp}

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)!}

Trackbacks

  1. [...] Link: Davey Shafik PHP Interview – The Best Thing About PHP Is The … [...]

  2. [...] 7php.com blog today they've posted the latest in their series of PHP community interviews – a few questions with Davey Shafik, the original author of phar. In this edition I talked with Davey Shafik (@dshafik), who is one [...]

Speak Your Mind

*