SVG as your MVC View

Lately, I’ve been playing with the SVG format - a W3C backed XML format for Scalable Vector Graphics. Firefox can now render SVG natively, and this opens the door for lots of fun things you can do with it.

There are already very nice implementations of PHP classes that, for example, generate nice graphs using SVG - although I’ve never used it, the eZ Components Graph module is a very good example.

However, if you are looking to generate graphics dynamically from a pre-built template, you don’t really need to use any libraries or heavy OO and XML abstractions. Since SVG is just another type of XML, just like XHTML, using PHP to generate dynamic SVG is quite intuitive. Looking at this from an MVC perspective, you can think of SVG as yet another form of view for data - and it can be quite easily used as a “template” just like XHTML is used.
It is also quite easy to embed SVG into XHTML or vice-versa - but this means that you will need an SVG capable browser in order to render the page (did I already mention Firefox is one?)

I am still playing around with the format and with the whole concept - but in the mean time, here is a (non-scalable png) screenshot of an SVG graph I generated using simple PHP code:

SVG Graph

You can see how this graph is embedded within XHTML and generated here - it also shows the entire source code. A few notes though:

  1. I have no idea how other browsers render this. It works with Firefox - I’m quite sure IE (even 7.0) does not render SVG without special plugins
  2. Pay attention to the header() call - it’s important!
  3. The use of Zend Framework is there only for fetching the data from digg - the real stuff doesn’t rely on Zend Framework

If I have enough time (and I’m able to get myself to focus ;) ) I’ll study this some more and maybe build some nice tutorial.

Zend_Service_PayPal proposal

I submitted my new Zend Framework proposal for a Zend_Service_PayPal component for community review. Hopefully, I’ll get some good comments and we can get this idea rolling.

The purpose is to utilize PayPal’s new NVP (Name-Value Pairs) interface and to provide easy access to it from PHP through the Zend Framework component.

PHP Norge Meeting

I went with a few guys I’m working here in Oslo with to the first meeting of the Norwegian PHP users group - although I didn’t understand much (I don’t speak Norwegian) I kind of got what was going on - and it was lots of fun.

It’s always nice to meet PHP enthusiasts and drink some beers. Derick Rethans was also there (apparently he lives in Norway) and it seemed that we were the only “foreigners” (although he does speak Norwegian quite well as far as I noticed).

There was also a PHP Quiz and we won - the prize was a bag of M&Ms which we kind of shared with everyone else - mostly because the questions were pretty much taken from the Zend Certification sample questions - so I pretty much new the answers without really understanding the questions ;)

Pictures from the event are available - I also have a couple of pictures I might upload later during the weekend.

Intercontinentalia

After something like two months at home, I went out on another journey for Zend, and this time it’s quite hectic.

I’ve spend last week road tripping the UK (I wasn’t driving thank god, but we did cover several hundreds of miles). Then, unexpectedly, I was called in for a weekend in Paris - so I took the Eurostar (first time) which was quite disappointing (maybe because it was night) and arrived at Paris on Thursday night.

It was quite nice getting back to Paris after almost 4 months of not visiting it, and our French teem seems to be getting to be quite a team, so it was quite nice - and short. Unfortunately it meant I missed spending St. Patrick’s Day in the UK - which could have been quite an event.

On Saturday evening I flew back to Heathrow to catch my original flight the next morning to Oslo - which is where I am now. I’ll be spending the next week and a half here, delivering training, and then head back to stickey-moist Tel-Aviv, and move into my new appartment.

Oslo seems to be an exciting city at first glance (most cities are!) so I hope it’ll be fun. I’ve read about the first meeting of the local PHP Norge users group on Thursday - so I might just pop in, after some sniffing around (it’s not always a good idea to barge in to these kind of meetings without asking first…)

I have to say the highlight of this trip so far was the fact that I met a new colleague in Paris, who apparently was reading my Blog without even knowing I’m the author. This means people read my Blog! Yey!