January 2012
2 posts
2 tags
Symfony2 Security Voters
I answered this question on StackOverflow today that is probably worth repeating
here. The poster was asking how to implement subscription-based authorization
logic in Symfony2. I imagine he models his problem something like this:
class Subscription
{
const SECURED_AREA_FOO = 'FOO';
const SECURED_AREA_BAR = 'BAR';
// ...
/** @ManyToOne(targetEntity="User",...
1 tag
Twig Node Visitors (Part 2)
This is the second in a series of articles on Twig node visitors. Please read
part one first.
Node visitors can be used for any number of things. The
Twig_NodeVisitorInterface interface itself is just three methods:
interface Twig_NodeVisitorInterface
{
/**
* @return Twig_NodeInterface The modified node
*/
function enterNode(Twig_NodeInterface $node, Twig_Environment...
November 2011
1 post
1 tag
Getting Twiggy With It: Node Visitors
I am going to write about node visitors: one of the more obscure but powerful
concepts in Twig. To help make sense of it I will be using a simple, real
world example.
At OpenSky we recently added a basic CMS to our site that allows us to make
edits to text without going through the hassle of editing a template and
redeploying the entire codebase. We added a module to our admin that manages
these...
October 2011
1 post
1 tag
Cancer
I’ve been sitting on this for awhile and think I should share now.
My wife of 7 years, partner of 10 and mother of my three young children was diagnosed with stage 4 breast cancer a few months ago. It’s been an extremely difficult fact to come to terms with. The diagnosis is serious, but we are very hopeful. She has just finished her third round of chemotherapy and the scans say all...
January 2011
1 post
1 tag
My first passport...
…has expired! I have stamps for these countries:
The Bahamas
France
The Netherlands
The British Virgin Islands
Japan
What will the next 10 years will bring?
December 2010
1 post
October 2010
11 posts
1 tag
Unit Tests, Mocking, and PHPUnit 3.5's new Mock... →
My latest tidbit of testing goodness, this time on the OpenSky engineering blog.
1 tag
Look Behind the "Feature Veil"
I’ve been thinking about a decision Apple made awhile ago to allow free iOS
apps to offer in-app purchases. My recollection of their argument against
doing this is that users would be frustrated by downloading a free app only to
have to purchase something in-app to get it to work.
Around the same time Apple decided to allow free apps to offer in-app
purchases, the App Store also began...
1 tag
1 tag
Keep a trim autoloader
The symfony 1.4 autoloader works by scanning your PHP class files and
remembering where each class and interface is defined, so it can magically
load it when needed. This class-to-filename mapping is stored as an array in
your application’s cache directory.
You can (and should) look at this array by opening this cache file in your
text editor from time to...
3 tags
My MongoDB slides →
I had a great time talking about MongoDB and the Doctrine ODM at PDXPHP last night. Thanks to ShopIgniter for hosting (and deciding OpenSky is not a competitor — phew!). I’m looking forward to talking about these things more someday.
1 tag
The Geek Talk interviews… Me! →
1 tag
Joining OpenSky →
I blogged about joining OpenSky last week, and about the compatibility of the OpenSky and open source philosophies, as I see them.
2 tags
RFC: Mocking Fluent Interfaces in PHPUnit
I sent a pair of pull requests to Sebastian this morning for a very simple change that will make mocking fluent interfaces much easier.
This is how you might mock a fluent interface using PHPUnit 3.5.1:
$mock = $this->getMock('Person');
$mock
->expects($this->any())
->method('setName')
->will($this->returnValue($mock));
I’ve proposed a new returnSelf() method,...
2 tags
2 tags
How to Test a Symfony2 Bundle
The Symfony2 Framework is fully unit tested using PHPUnit. When you create a
Symfony2 bundle to share with the community, it’s important that your bundle
also be fully unit tested. It’s also important that users be able to run your
bundle’s test suite without having to wrap it in a dummy project. This blog
post is about how to set that up.
PHPUnit Configuration
Configuration...
July 2010
1 post
2 tags
How to create a Symfony2 templating helper
As you get started with Symfony2 you will probably find yourself getting stuck
on some tasks that are second-nature to you when developing in symfony 1. One
of these will probably be adding a custom helper to your view layer. Hopefully
this quick article will clarify that particular process.
Create a helper class
In order to work with the Symfony2 view layer your helper class must implement
the...
February 2010
1 post
2 tags
Blog Post Cut Short
Me < Metro < Paris
I would like to eat a crepe.
What more can I say?
That about sums it up! I’m headed to the symfony live training day, bracing myself for the first of three OSS geek-out days.
I arrived in Paris yesterday morning after flying nine hours up and over the top of the world, getting nary a wink of sleep. This is my second trip to Paris and my first flying...
August 2009
1 post
Shifting the Sun
When your father dies, say the Irish,
you lose your umbrella against bad weather.
May his sun be your light, say the Armenians.
When your father dies, say the Welsh,
you sink a foot deeper into the earth.
May you inherit his light, say the Armenians.
When your father dies, say the Canadians,
you run out of excuses.
May you inherit his sun, say the Armenians.
When...
July 2009
8 posts
1 tag
How to Spam Twitter in 3 Easy Steps (or, The Death...
Despite the fleeting “spammers perish” event a few days ago, my Twitter profile is still overrun by spammy followers. This is really bugging me. I’ve been forced to switch notifications off, and my stop_jackin_it.php script isn’t working because the /blocks/create API method is broken. This will be the downfall of Twitter if it isn’t contained.
So you want to be a...
2 tags
Doctrine and MySQL integers
I just pasted this somewhere handy for my own reference. It’s the logic Doctrine uses to translate the integer data types you specify in schema.yml into a MySQL data type. If you’ve ever wondered why the length you set on an integer isn’t directly translated to the table definition used in your database, here’s why.
For example, the id columns in sfDoctrineGuardPlugin are...
1 tag
stop_jackin_it.php
I’ve been getting inundated by followers who appear to be normal people with a healthy number of followers, but have links to xurl.jp spiced throughout their timeline which resolve to… wait for it… porn.
I’m sick of it. So I did something about it. I cronned this script on my computer and you should to. It will run a search for the string xurl.jp and block anyone posting...
2 tags
Symfony: Denote Required Form Fields
You can checkout the full gist for this tutorial
here.
The symfony form framework separates a form’s presentation and validation into
two distinct collections of classes: widgets and validators. For the most
part, these two codebases live happily without any knowledge of eachother.
When data from the validators needs to be shown in the presentation layer,
such as in the case of error...
1 tag
MooTools: Bubbling Controllers
This one’s an oldie but goodie I just pulled out of my tome of a ~/Sites
directory. Similar to Aaron Newton’s concept of Events
Arbiters,
this class fires events for one object on another object, but I’ve applied the
bubbling pattern you may be familiar with from native DOM events. Instead of
bubbling up a hierarchy of elements, we just bubble up a hierarchy of
controllers.
...
2 tags
MooTools: Ignoring the next click
I’m a big fan of MooTools, as I recently tweeted. I typically try to extend this framework as little as possible, since that can be rabbit hole for me, but this method is just too handy to pass by.
The use case I’m working with is distinguishing between a drag/drop interaction and a click interaction on the same element. If you’re dragging an element, the click event will be...
4 tags
Managing Master and Slave Database Connections...
This is one of those things that should be much easier than it is. Since I
started using Doctrine a few months ago, I’ve been impressed with how complete
it is, but I can definitely see room for improvement as the project matures.
Setting up read and write connections is one of those areas.
My challenge was to get the project I’m on ready to be hosted on Amazon EC2,
with the help of...
2 tags
Doctrine Timestamps and User Timezones
I recently added a “timezone” dropdown to the user preferences screen on a symfony application currently in development. This simple extension to the sfDoctrineRecord class makes it easy to present times from the database in the current user’s timezone.
abstract class myRecord extends sfDoctrineRecord
{
protected function _get($fieldName, $load = true)
{
if ($value =...
No one is further from the truth, than the one who has all the answers.
– Chinese proverb
June 2009
7 posts
2 tags
svn import: inconsistent newlines
I encountered this error ad nauseum while importing external libraries into my local/offline Subversion repositories:
File ‘/foo/bar’ has inconsistent newlines
At first I was opening each file in Textmate and then “save as”-ing with Unix newlines. This takes way too much time, so I wrote this little PHP diddy:
<?php
// Usage:
// php smart_svn_import.php ....
Swan Song
We are travelling north to Cognac today, then back to Paris Sunday night, then flying to Portland on Monday morning. I promise I’ll get some pictures up soon!
1 tag
Travel Fatigue
The inevitable has happened: travel fatigue officially set in a few days ago. Six weeks away is a long bloody time. Just comprehending that has been an experience in and of itself.
We drove from our last place, near Najac, to near Biarritz on Saturday, where we’re staying in an old mill of some sort. The house was built in the 1500’s and is right on a small river. The mill itself has...
Travelling to the coast today. I’m not sure if I’ll have access to the web down there. If not, I’ll be back in a week!
1 tag
From the middle of nowhere
I can’t believe my four weeks in Paris went by so fast. But they did, and now we’re holed up in a house 8.5 hours south of Paris, listening to a magnificent thunderstorm outside.
First things first. My time at Sensio was very nice. My primary takeaway would have to be shaking hands with everyone at the start of every day. I haven’t experienced this in the states: I saw a lot of...
2 tags
Two ZendCon proposals
I submitted two 400-character proposals to ZendCon yesterday.
Someone else’s symfony
Taking on development of a symfony application started by another
developer can be a daunting task, especially for those not familiar
with the framework. This will be a practical exploration of
symfony from the perspective of a developer taking on an existing
project. Topics will include getting...
May 2009
23 posts
1 tag
Finally, a day in Paris
My wife and I finally got a chance to experience Paris in leisurely style yesterday. We started in Île Saint-Louis around lunch time and had a very nice meal with a great view of the back of Notre-Dame and a pleasant breeze off the Seine.
After our meal and some coffee we strolled the island while enjoying some ice cream and sorbet, supposedly the best in Paris. We bought some gifts for folks...
1 tag
Willy Wonka's Nespresso Factory
My most surreal experience this trip was my trip to the Nespresso store yesterday.
When I came up from the Metro I was greeted by the old Opera house, which is gorgeous. I didn’t have the exact address with me, so I checked my iPhone for an available Wi-Fi network. I was able to connect to one called “Google-Guest” and find the store in the maps app.
The store itself was like...
1 tag
Symfony in Concert gets a little attention
I’m happy to report symfony in concert got a little attention yesterday. I sat down with a designer here at Sensio and discussed the forthcoming microsite: something clean that can be built quickly. I think it’s a challenging design because the site is targeted toward two disparate audiences: developers and social organizations. Preparations for symfony live have taken the front seat...
1 tag
Ten Days In
Today will be my tenth day in Paris. I’m on the bus now, headed to lovely Clichy and thinking about how unprepared I was for this sort of trip. It’s challenging to be “a stranger in a foreign land,” but of course I would have been naive to expect anything different. I don’t speak the language, for goodness sake!
Living in a big city is also an adjustment. I’ve...
1 tag
1 tag
Interactive timetable for the Paris Metro in... →
1 tag
Using my iPhone internationally
No, I didn’t unlock my iPhone. Rather I’ve locked it down with a few key settings that allow me to continue my multitouch love affair without paying AT&T through the nose.
The first thing I did upon departing for France was confirm the international data roaming option was switched to off (I think this setting was patched in by Apple after people starting getting upset by...
1 tag
Jet lag complete
I guess one more post on the jet lag tag wouldn’t hurt, but only to report we finally seem to have fully adjusted. Last night was the third night we all slept straight through (although I was up a bit late working). That means it took my two year old six nights to adjust to a nine hour change, my three year old five nights. Looking back on it that actually seems pretty good :)
1 tag
Pedestrian injuries
I’ve seen at least a dozen young people walking around with crutches and one woman being placed on a stretcher after being hit by a car today. Is this just city life or some kind of epidemic?
1 tag
Waiting for the Metro, thinking about Forms
I’m below Paris waiting for the 13 and thought I might take advantage of this time to post here…
Things are good! My first days at Sensio have gone well, although I’ve been bailing around lunchtime to catch up on sleep. Fabien and I have been working on that-which-cannot-be-revealed and discussing bits of symfony, components and the like.
I recently introduced the...
1 tag
Le Bistral
My wife and I just returned from a delicious meal at a neighborhood bistro. I had veal liver and she had duck tenderloin. It was extraordinary. I think the joint is called Le Bistral (on Rue de Moines).
My wife doesn’t think we can do any better but I find that hard to believe. The food was out of this world, but this is Paris, you know?
1 tag
Symfony Components →
Symfony just put the PHP world on notice.
1 tag
Saturday morning
Hopefully this will be my last post on the jet lag tag. It’s Saturday morning, our 4th in Paris, and everyone is still sleeping. My son was up at around 3am again, but after a few hours he eventually fell back asleep. That’s real progress.
I, meanwhile, am watching A Bug’s Life on my iPhone, retweeting the new symfony components site, and waiting for the bakery across the...
2 tags
Day 3? 4? Maybe 2?
The kids were up early again this morning. I think it was 3-something when I glanced at my watch. Recovering from jet lag is definitely a multi-day ordeal.
Once this half of the world wakes up I’ll be heading into Sensio and hopefully resolving our mobile phone concerns. I think we’ll all feel a bit more comfortable venturing out into the city once we have phones, especially when the...