PHP, Zend Framework and Other Crazy Stuff
Archive for March, 2007
Zend_Yaml Proposal added
Mar 26th
YAML is a machine parsable data serialisation format for storing text, numerical data, arrays and more. It was designed for use with programming languages and has excellent support in Python, Perl and Ruby. Several C implementations exist and at least one (Syck) supports a PHP extension. If that explanation escapes you it’s a bit like having XML, only without the tag soup where nesting is related to indentation.
Now PHP has been slow (really slow) at adopting YAML in a serious way. As I previously noted PHP’s support is limited to the PHP Spyc Library, and a PHP extension which relies on the Syck C Library. The PHP extension has no PECL presence so it’s visibility to PHP developers isn’t the best but it is by far the fastest and more efficient YAML parser for PHP which benefits from the fact that the Syck Library is standard in Ruby since 1.8, and available for Perl (check CPAN) and Python.
So isn’t it time there was something native to PHP to allow everyone work with the YAML format? Well, I think so… So last week I ran off and did some digging, coding, and sacrificed a few white pigeons to the dark gods of inspiration. Once the pigeon blood and other…eh…bits were mopped up, I wrote the proposal for the Zend Framework – read it here. It’s nothing fancy, just a general outline and some sample use cases.
In the meantime I spent some time going over the cool pyyaml reference parser. Zend_Yaml will take it’s cue from pyyaml, with a pinch of personal OO improvement (not a Python “import from *” fanboy I’m afraid – too many methods floating between classes!), and a dash of PHP5 for added flavour. Keeping track of indentation will be painful to say the least – there lots of column, pointer, index messiness to get confused with but in general it’s straightforward enough. Just time consuming
.
YAML for the Zend Framework – well, maybe…
Mar 21st
It’s funny sometimes how you end up being involved in an open source contribution
.
A few days ago I was on the PHP Developer’s Network forums – not so surprising since I like being involved there and the problems you run across can get you thinking about new ideas and learning new things. I was responding to a theory post about adding a filter/validation chain to the Zend Framework and suggested the end result should be configurable – i.e. if I have a configuration file, a Factory class should be able to easily generate a filter chain without manual tinkering (something I absolutely hate doing is manually setting up filters and validation since it’s a pain in the ass to modify by hand later). In any case being configurable would be a good pointer to the simplicity (KISS) of use in setting up a chain if nothing else.
Since I’m used to the format from Ruby and Perl and since it’s used for a similar purpose in the PHP Symfony framework, I also suggested using YAML configuration files since they are far more readable than XML and remain machine readable. I believe this went over quite well. Later on I realised the Zend Framework has no YAML support, and after some searching noticed the only (apparent) PHP parser was the Spyc library. Now kudos to the Spyc developers because it works – but it’s not a full grammer parser (that I could tell) so I’m not sure exactly how compliant with the full YAML 1.1 specification it is. I haven’t tested it so I’m not judging.
So I fired off a few emails to the fw-general mailing list of the Zend Framework to see if there was any interest. I’d like to thank Matthew and Gavin for their feedback and I’ve since decided to have a go at implementing a YAML parser in PHP.
Now before folk go off the deepend, there is a PHP5 extension which is based on a YAML parser and emitter in C called “Syck”. Those of you in other languages are likely vaguely familiar with the Syck bindings for Ruby, Python, Perl, etc. But since YAML is overlooked in PHP to such a huge extent it’s pretty hard to pin it down for PHP5. Gavin Vess posted a link to Gentoo Linux in a reply which shows it’s available and being maintained.
So, YAML Parser – where to start? YAML has a few defining format characteristics – it’s so useable because it’s written in a typical western style, top to bottom and left to right. Nesting of YAML nodes is based on indentation levels (likely the main “problem issue” of sorts). In addition the syntax is fairly simple to learn though those single characters call for having a reference card posted over your PC unless you’re a total YAML fiend.
A quick look around the web at the most recent YAML parsers pretty much confirms that LL(1) parsers have gained widespread adoption for YAML. It’s easy to see why since the grammer set is short and an LL(1) parser (recursive descent) is simple enough to implement and test. I see no reason not to take a similar approach. I’m going to dig around at putting together a Parser structure over the weekend – something to get the ball rolling and provide fodder for a formal proposal.
Using online activity to assess prospective employees
Mar 16th
A while back I was reading a blog post by Jim Plush titled “What separates a professional PHP web developer from a scripter?”. In general it’s a good list, and should provide good advice for many an aspiring developer. However one point in particular raised a red flag:
I should be able to find all sorts of good things on google that you’re doing with php or web technologies, It generally is a red flag when I google you and nothing comes up(bonus points for having a project of your own or contributing to one).
The problem here isn’t finding and assessing a developer’s past work – any developer ought to have a few show pieces to show. It’s the idea of googling for an individual as having a red or green flag effect.. I’ll be cautious and note Jim used the word “generally” in there suggesting there are exceptions. Hopefully.
I’m a prime example, stick the following into Google: “Pádraic Brady”. Now go google – you’ll realise after a page or two that I seem to have only existed for scarcely a year, primarily on the PHP scene, and a little bit for much longer on some Linux and Irish websites (though my name is not quite as rare in Ireland so don’t expect to know which is me
). That’s the length of time that’s passed since I became more willing to use my real name on the internet, in a very limited way. Before that, I have used a collection of internet handles. In PHP, you’d see “Maugrim The Reaper” more often than not – assuming my blog title didn’t give that away!
Going back a year, if during an interview a prospective employer decided to comment on my lack of online existence I’d have likely started getting worried. I’ve been on the internet since the mid 90′s, since secondary school, and likely have posted a lot of stupid ignorant insanely offending messages. So do I a) tell the employer I operate under internet handle A and let them trace my existence for 10 years online, or b) refuse to hand the employer any personally identifiable details, or c) avoid the issue and hope I fall into some exceptional case reserved for privacy sensitive individuals not wishing to offend an employer by saying “no” straight out?
It raises a pretty intriguing question. How far should an employer value that online google check? Low or high? Personally, I’d lean towards low on the basis that if a prospective employee had a community involvement or a personal project they forgot to mention then they are either inexperienced in being interviewed (prod and prod again
), or just don’t have any. Checking online would be hit and miss. If I checked myself 12 months ago I’d be spitting red flags because I would have walked out of the interview rather than give up a list of my precious online anonymous aliases. Screw that.
Today I couldn’t care less since my name has been barely used online for a year, and I’m almost certain in a non-offensive manner
. It’s become a plus to associate my name with this blog and my own meagre contributions to the PHP community. I still however use multiple aliases which effectively isolate varying interests and online activities from each other – enough to defeat the tracking schemes of the average google-read-opine folk who aren’t willing to dig around for a while. My “Maugrim” alias will net you little more than early PHP development on an online game (’00 to ’03) and some references to the alias’ source in a Yahoo Club (now Group) back in ’99 where Maugrim The Reaper was a pissed off Irish druid in an RPG fiction writing club
. For those who’ve linked their entire identity, online actions, and blunders to a real name or singular alias however it’s can be a pretty tough position.
The reason I raise this post is because I actually know people this impacts. I’ve seen 3 people over the last few years do their living best erasing themselves from forums, and opt-in services to get rid of their past. I know two of these were definitely having issues with employers. None actually noted an employer name, so it seemed to revolve around how easy it is not only for employers – but lest we forget, CLIENTS – to do an idle google for a name. Herein lies the danger of singular identities online – if you don’t keep yourself ringfenced to an alias, or at the least wary about openly posting certain types of, eh, criticism under a real name then you can be fried. Hell, two years from now I might regret using my real name in this entry… That would (or will?) be a shin kicker.
Still doesn’t answer how to respond to that employer question about your online contributions… I don’t have one if an employer puts too much value on prying (sorry, checking) into a person’s private activities online innocent though they may see it.
Progress update on Zend_Service_Yadis
Mar 12th
As covered in two previous blog posts which formed a quick tutorial, Yadis is a specification which describes a protocol for retrieving Service information valid for a specific ID. As I noted then, the simplest example is figuring out from a user’s OpenID where we should fire off authentication requests. In OpenID, Yadis can be used to grab a user’s XRDS document, an XML list of services which should provide the URL and service types of the user’s OpenID Provider.
Back in late February, I submitted a proposal to the Zend Framework wiki to see if Zend_Service_Yadis could be added as part of an overall objective to natively support OpenID (and related technologies) within the framework. Yadis is a suitable standalone service since it’s not OpenID specific and is therefore useful for a number of other purposes. That proposal has seen a few revisions since the initial draft so I’m hoping that by the time Zend Framework 1.0 is released it’s in good enough shape to allow for a comprehensive review and critique.
Of course, since I’ve taken a break from my other personal projects, I also started on the coding immediately. This is being versioned over at http://svn.astrumfutura.org (subversion url) and is viewable online with php syntax highlighting at http://websvn.astrumfutura.com (see Yadis.php and the Yadis subdirectory).
Anyways, this is progressing towards “completion”. I won’t say it is complete (or even so much as Alpha quality) until I know for certain whether it’s an acceptable Zend Framework component or not. If it is, further review and requirements may be made by the reviewers and public which would form the basis for any acceptable release.
A few quick points. The component will not support using Internationalised Resource Indicators (IRIs) since they cannot (yet) be validated by the Zend Framework. This is rather difficult considering each national registrar has varying character restrictions within IRIs, and that IRIs would need to be mapped (punycode) to a matching URI before use. Support for XRIs will be supported, but may not initially be concrete. To be honest I find the concept of the XRI unintuitive, they don’t seen to offer any compelling advantages over the URI, and it’s not like browsers support them. Still, what the Yadis and OpenID specs declare is what I need to implement.
For those out there curious about implementing OpenID, or Yadis, your feedback and comments would be welcome. I suspect most would prefer commenting on a full OpenID component since that’s where all the excitement is at
, so hopefully I can slot in a fuller OpenID proposal in the near future once the Yadis implementation is fully stable.
Join the New York Parade! (But gay people need not apply)
Mar 5th
St. Patrick’s Day, that time of the year when we Irish take the opportunity to attend mass (for once if we’re not practising), see those odd family members who only appear usually at Christmas, and of course loyally wait for the local village parade to swing down main street in all it’s glory. Alright, so a parade of tractors, trailers, the local school groups and clubs, and the odd humourous jab at the government are not necessarily glorious, but every village in Ireland does its best effort.
Amid the build up I was surprised to learn that the New York City Council Speaker would be attending the Dublin Parade at the invitation of the organisers. Surely, I thought, she’s be at the huge New York Parade? Apparently, she is not welcome to march in the New York Parade however, since she happens to be gay. Huh? You know, Ireland isn’t exactly bursting at the seems with tolerance – we’re still heavily entrenched in a conservative mindset though that has changed drastically over the decades.
Apparently the Ancient Order of Hibernians has banned gay folk from marching in the New York Parade – so what happens? The Irish people in Ireland have to invite a prominent member over to Dublin so she can openly partake in a St. Paddy’s Day parade to rival New York’s. I hope the AOH take this as a firm shot across the Atlantic from the ol’ country – St. Paddy was a saint, not a discriminating bigot. If we Irish can shrug and tell gays and lesbians to take up banners and join the party (why not?), then surely those old fogies over in the AOH can see their way to being a bit more inclusive in the future. Afterall, we’re celebrating the birth of Christianity in Ireland by an infamous nobleman turned cleric who spent his youth enslaved by the very people he returned to teach and convert. Patrick wasn’t discriminatory – he returned to Ireland and made it his job to convert his one time tormentors.
So why should the AOH be free to taint our celebration of the great man himself in such a ludicrous manner? Because they belong to some “Ancient” order? Honestly… Surely these jokers have better things to do than tell everyone who can and cannot take part in a celebration of a great and famous Saint? Really, look at a calenders boyos – it’s the 21st century. Get in line with the genuine Irish people over here on our wee little island with our quant little parades in our picturesque towns where gay people can throw up a banner as is their God given right as Irish people.
