Skip to main content

Posts

Showing posts with the label symfony

My new way of using PHP Traits & Interfaces

A popular feature in Rails called "mixins" came to PHP a while back under the name "traits".  Traits let library developers give you a lot of functionality with little to no effort by injecting code into your classes that runs as if originally authored in them. Just toss a line of code into the class you want to augment and you're off to the races. The one snag I found when using traits however is that they don't participate in any kind of type system.  If desperate enough, you can use reflection to pull out whether a class has one applied or not, but that's only half the battle and a lot of work each time. This puts me in a slight bind when I'm interacting with classes using a trait I've made as I have no way to type check or hint them in. But then it dawned on me... interface MyInterface { public function thisMethodIsImportant(); } trait MyInterfaceImpl { public function thisMethodIsImportant() { return "Thanks...

Your Server-Side Form Library

If it isn't already obvious from my previous posts, I've been spending a lot of time on the client side of things with JavaScript and the Dojo toolkit. I had a chance last weekend to show off a little bit of Dojo and once I got past the lightweight technique for bootstrapping it from the server , my demonstration suddenly got a lot less glamorous. I think part of it got lost amidst what resembled gruelling swing form code.  I was lucky in that I already had some completed forms to show off, so it was possible to show the kind of experiences you can deliver when you use a good client-side framework. There was however a takeaway for me which after a lot of thinking, I think I've managed to figure out... It's Holding you Back! Your server side form library is killing your UX, coupling your model to the view and tying down your options client-side. I've worked with forms in Symfony 1.4 extensively and have become quite adept at bending them to whatever need ma...