The PHP Hierarchy of Needs

We had a lecture about Unit Testing in our local PHP user group last week. I really like these meetings because there is usually good interaction between some very experienced developers and some very inexperienced ones.

Following the usual “but why is it better then just running it in my browser and seeing that it works” question made by one of the younglings, we got into a discussion of why Unit Testing it so good, and especially, why is it such an addictive practice and why people who do it (including myself) tend to love it so much.

And then it hit me: [more...]

Travel Plans

After what is probably the longest period of being at home without flying anywhere (since November!) in the last 3 years, I am actually quite excited to be flying again.

After a quick visit to Zend’s Cupertino office, I will be attending two conferences in may: I’ll be visiting the last couple of days (May 22nd - 23rd) of php|tek in Chicago - in which I will not be presenting, but will probably hang around with the Zend guys and go to some lectures.

After spending the weekend with friends in New York City, I’m flying to Germany to attend DLW Europe - a first-year conference dedicated to dynamic languages (PHP, Ruby, Python, Perl etc.). There’s quite a lot of known PHPers attending and speaking, and it looks like it’s going to be a blast. Personally I will be giving a talk I call “Non-framework Zend Framework Components” (working title) - which will showcase some of the more useful components of Zend Framework for those who do not want to base their entire application on it - but rather just need to preform tasks and want to reuse the high-quality components of ZF in order to do that.

So it looks like quite a road trip: Tel Aviv -> San Francisco -> Chicago -> New York -> Karlsruhe -> Tel Aviv - by the end of it I might be able to buy a MacBook Pro using frequent flyer miles only ;)

If you’re in either conferences - come over and say hi!

Security By Obscurity - “Not to Stand Up”

I am giving a security lecture at the local PHP users group tomorrow, and one of the topics is, ahm, security by obscurity. In fact, it’s not really a topic - I just mention it and say that it’s not really an approach to security, and should generally only be used as an extra measure and should not to be relied on.

This got me thinking about one of my old-time favorite Monty Python sketches:

The first rule of not being seen: not to stand up!

New year, new position

I spent the last 2.5 years working for Zend’s Global Services department, first as a technical support engineer and later as a technical consultant. I’ve learned allot and met lots of very smart people - but for some time now I have a feeling it’s time to move on.

Apparently, some people at Zend had the same feeling - don’t worry, I wasn’t fired. I didn’t quit either. Starting from January 2008, I am now a part of Zend’s Product Management group.

My new and awesome title is “Senior PHP Specialist” which kind of means nothing (and that’s what so good about it!). My actual roles are varied and flexible and involve duties such as competitive analysis, benchmarking, prototyping, meeting with customers and PHP community folks, and generally getting more customer and community feedback and touch into Zend’s product line. I’ll be working with all products - mostly Zend Platform, Zend Studio and Zend Core, and will also maintain my involvement in Zend Framework, and perhaps other projects as they come.

I have to say this has the potential of a dream job: it’s hands-on, and yet very dynamic. It’s community related and touches commercial products. It means working closely with services people, R&D, and customers (and PHP users who are not our customers!). It involves studying emerging technologies, programming, testing software, writing and reading papers and generally keeping a finger on the pulse of the web.

Oh, and did I say my new direct manager is Zeev Suraski?

So good luck and happy 2008!

PHP Israel: First meeting

Yesterday we had the first meeting of the newly founded Israeli group of PHP users, or “Kvutzat Mishtamshey PHP Beysra’el” as one might say.

The meeting was held at Zend offices, and there was a pretty good turnover - ~20 non-Zenders showed up with ~10 more Zenders joining in. I gave a presentation (slides are in Hebrew but you can get them here if you read that funny language) about the past, present and future of PHP. There was also a trivia quiz (yes, I stole some ideas from a PHP Norge meeting I attended some months back) and we gave a book and a couple of T-Shirts (and a PHP stress ball) to the winners.

Boaz took some pretty good pictures as well.

It was lots of fun and good socializing which was exactly what I hoped for. The general idea is to have a meeting once a month or so - hopefully, next time I will be sitting and asking questions and not presenting.

Thanks everyone for coming, and if you happen to be in Israel, and do PHP - you should come as well!

That’s why I got so many business cards printed!

A few days ago my work Thinkpad T43’s screen started flickering (not flickring, actually flickering). I immediately dismissed it as some kind of broke-my-Gentoo thing I always do, but after rebooting to Windows (yeah, it’s still there - IT demanded I keep a Windows partition), I realized it’s a hardware problem - something is fucked up with the backlighting or something. It got worse until a couple of days ago it started going blank for hours, and only coming back randomly for 5 minutes every time.

Now, this would all be fine if I wouldn’t be in the middle of a training engagement in India - and a week from returning home. Projecting still worked - so I could go on training, but I couldn’t do anything except for that - plus it doesn’t really feel nice that during breaks all your students can still watch your desktop ;)

Anyway while not giving up to hardware, I found out that if I apply pressure at certain points on my screen, it goes on - that made me spend hours massaging my screen trying to get it working, but whenever I got my fingers off it it went dark again.

I almost thought of giving up and started thinking about finding an IBM service center or something (or is it Lenovo?), but that soon realized as impractical. Since doing customer engagements for Zend away from home always feels a bit like a military operation (that’s an Israeli thing: Israeli men tend to compare hard / exciting / surreal situations in their lives to military related experiences - even if they don’t admit it out loud…), I suddenly remembered something one of my officers used to say whenever we complained our equipment or supply is crappy: “This is all we have, and that’s what we’re going to win with!”. All motivated, I started MacGyvering, trying to get my screen working back with a toothpick and some chicken curry (that’s mostly what I have here).

Finally, I came up with this solution:
How I fixed my T43's screen

In case you’re wondering, that’s one of my Zend business cards I always carry and hardly use :)

Off topic: yes, I’m in some kind of photo-taking craze. Perhaps I was bit by a Japanese vampire or something.

Happy New Year, PHP Israel Users Group!

As some of you might know, the beginning of year 5768 of the Hebrew calendar is being celebrated in Israel these days - and for the new year, me and some friends decided to try and organize PHP-Israel - a local PHP users group in our land of milk and honey (or was itblood sweat and tears?).

So now we have php-israel.org (sorry folks, it’s all in Hebrew). It’s been around for less than 2 weeks and we already have ~40 or so subscribers to the mailing list - quite allot are Zenders but the majority are not, which is good. We also have some traffic - people are designing a logo and talking about a first meeting.

I’ve always thought there’s no PHP community in Israel - now I know there isn’t one because nobody tried to organize the quite numerous individual PHPers into a community. Hopefully, by next year, we will have a thriving local community of PHP users, spreading the word of the free web in Israel.

Shana Tova, PHP Israel!

Solve a CAPTCHA, help the world

I’ve just stumbled upon a great idea named “reCAPTCHA”. The idea is that you use their CAPTCHA challenges to protect your site from spammers and bots, or to hide people’s email addresses - but the cherry on top is that when people solve CAPTCHAs on your site, they also help digitize books by filling in words that OCR could not process.

According to the creators (from the site: “reCAPTCHA is a project of the School of Computer Science at Carnegie Mellon University “):

About 60 million CAPTCHAs are solved by humans around the world every day. In each case, roughly ten seconds of human time are being spent. Individually, that’s not a lot of time, but in aggregate these little puzzles consume more than 150,000 hours of work each day. What if we could make positive use of this human effort? reCAPTCHA does exactly that by channeling the effort spent solving CAPTCHAs online into “reading” books.

So they take the words OCR programs fail on (meaning: those are hard CAPTCHAs for bots to solve in the first place) and ask humans to solve them - and when they do, they use the words to fill in the OCR blanks. Now how cool is that? I’m definitely going to look deeper into this when I have a few free moments.

They even have API libraries in several languages, including PHP.

What I have always thought is now official

Ever tried looking up your name in Wikipedia? Check this out.
I knew it - and the title says it all.

The M in MVC

In the last few weeks I’ve been thinking about models allot. Models, as in Model-View-Controller modules, are the most abstract and hard to frame-out part of this holy trinity (one might say Models are the “Holy Spirit” of MVC). So what’s the best practice here, if there is even one?

Models represent data and provide the means to preform data-specific actions. In a sense this is exactly what objects are (as in OOP objects) - so one might say that simple container objects are in a sense what the model should be. But in the real world, you almost always need data persistence, which means having some kind of storage mechanism to read from or write to. In the PHP world that’s almost always a database (and almost always MySQL) but it doesn’t have to be: Models could be based on RSS feeds, XML or other serialized data formats, web services, and more. In fact, $_SESSION could (and should?) be a part of your model. So data-layer abstraction could be a nice thing!

It gets even further - think about a model class which uses several data layers, mixing RSS feeds with locally stored meta-data for example; Or a Transaction class, that when saved, will both save local information in the DB and send an API call to PayPal, executing the transaction or fetching information from PayPal’s logs.

Well - getting back to my point, I was thinking about the best way to “frame-out” models and I have to say I didn’t come up with a good, practical solution. One of the conclusions I did made however, is that we are thinking completely wrong when designing our models. We (or at least I) have a tendency to design the model layer by starting from the storage and data access layers (the DB schema usually) and then going to the application layer. If you ever used Propel, it does exactly the same (as all ORM attempts probably do) - you design a database schema, and then build your model classes around it. Then, whenever your application requires some complex relations or data access, it becomes hell and you need to hack things together to make it work (try things like efficient batch updates, or efficient JOINs).

This is obviously wrong. We should be building or at least designing our application first - designing the logic, planning what sort data and what data related actions each action will need to perform, and then design model classes accordingly. These classes in turn will be used to design the data storage layer. The end result will probably be a set of classes for each DB table (or pseudo JOINed tables for that matter) but in run time, will be much more efficient and easy to use.

I am not sure how this can be done and even if this is possible - consider it to be a theoretical idea. But think of the possibilities when you start from the application layer and go down - instead of being limited by your data access layer.

You’re more than welcome to share any thoughts (or objections).