Skip to main content

Posts

Surface Pro 3 - Windows like Ubuntu

I had the great fortune of being sent to OSCON by my employer (we're hiring!) this year.  On top of getting to hear from lots of like-minded developers and learning about technology I might not have otherwise considered, I also managed to score some loot!  The most notable of which being a Surface Pro 3 which I had been coveting since their release, but had lost interest due to very steep prices. Getting it was actually an interesting process that I was perfectly okay with playing into because we're all at OSCON to have fun and learn. Being their main source of revenue, it's important that Microsoft fend off the impression that Windows is developer unfriendly.  So, the overall gist of Microsoft's booth at OSCON this year was to remind people that you can in fact develop using free and open source tools on Windows, a non-unix.  ( Curiously, I have been saying since the 90s that FOSS would be the norm and Microsoft's 180 on it of late is just more writing on the wa...

Laravel is Good, Facades Aren't

I've been working on some Laravel 4 based packages lately which inevitably results in me also looking at other packages. I've noticed sometimes that people use facades at times that give me pause. The most troubling being from inside their model classes. A quick google turned up this video which assures people "there's still an instance behind everything, we're fine" .  Everything mentioned in the video is true except that there is a very glaring omission. Scope What usually goes out the door at the start of a long series of mishaps in software design is scope . When the desire to obtain a solution is stronger than the desire to consider the implications of a firm approach, mistakes are sure to follow.  Sacrifices like this are made due to the assumption of a high cost to developing carefully. What really is happening however is a false dilemma , being responded to with a convenience decision . It's very easy to write model code like ...

Are you lost trying to do facebook opengraph and app dev?

Just a small blog post for developers trying to make heads or tails of how to work with OpenGraph, self-initiated likes and preparing web sites for facebook integration: These two pages seemed to give me the clearest bird's eye view of things: Like Like Button Migration I'd file this under "You didn't ask the right question!" , sometimes documentation fails to establish the basics and this is one example of that.

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...

Moving away from Laravel Facades

Are you looking for a way to resolve things like translation, validation and config from the Laravel IoC? Look no further! Make yourself a service provider (whether in a common tools package or in your project) and add the following to it in the register method: $this->app->bind('Symfony\Component\Translation\TranslatorInterface', function ($app) { return $app['translator']; }); $this->app->bind('Illuminate\Config\Repository', function ($app) { return $app['config']; }); What you've done is mapped all the string-registered services to their most abstract but also most specific types.  Config is a good example of where you should be binding the class name and not an interface because the only interfaces it implements are ArrayAccess, and that's obviously wrong! :) Happy constructor-injecting!

Laravel Project Architecture: The Missing Guide

At my job, we've been doing a lot of learning and development using Taylor Otwell 's Laravel 4 PHP framework.  As we've become more familiar with it, we've had to come up with better ways to structure our projects outside of what the documentation indicates and the default distribution that is provided. If you've been working with Laravel 4 for any amount of time or come with experience from another framework and are just getting started, you've probably noticed that there are a lot of different ways to cut up your projects. Choice is nice, but sometimes it can be paralysing or misleading. Concrete Advice This post is done in such a way that you can just skim the headings, but if you want a detailed explanation in each section, feel free to read in where necessary. While I can't say the entirety of my advice is in practice throughout the community, I can say that we are starting to use it, and to very good effect at my job.  Especially consider...

Recent tweak made to Laravel error handlers

For anyone configuring their own error handlers in Laravel 4.x, a feature suggestion I made has been implemented to have the handlers placed at the top of the queue rather than bottom. This default behaviour makes more sense given that as you get further into your app, you'll likely be defining handlers less likely to return a response, or more likely to want to pre-empt other error handlers entirely. While that's a safe assumption, there's still the mechanism to add a handler to the bottom of the pile with pushError() if you end up needing it still. Here's a quick reminder of how you can use either of these features: App::error(function (Exception $exception) { /* Your handler here! */ }); App::pushError(function (Exception $exception) { /* Your handler here! */ });