Sonntag, 25. November 2012

Doctrine MongoDB ODM: Storing arrays

When working with Doctrine MongoDB ODM, one thing I struggled to get right was arrays inside a document. I remember a few questions on StackOverflow who also didn't know how to handle this.

The answer is very trivial, but the documentation lacks a description, so I am posting it here (as well as adding it to the documentation of course):

class MyDocument
{
    /**
     * @Field(type="hash")
     */
    private myArray = array();
}


There is a Mapping Type called "hash" which mappes a PHP array to a MongoDB one.

Of course you need to remember that an array in a MongoDB document cannot have any keys but only values. If you need keys, that would be a new document which gets embedded (see the docs on embedded documents).

Sonntag, 18. November 2012

Using 37signals/sub inside a vagrant virtual machine

Todays topic may be a bit specialized, but I guess it could be interesting for some! 37signals released their shell script toolset (which has a very small footprint) to the public calling it "sub". You can find the code in their github repository and the relating blog post on their signal vs. noise blog.

As I am running windows, it seems that this toolbox is useless for me. But I am working with vagrant all the time, so there is always a linux running in a virtualbox. It goes without saying that using sub within a vagrant box is not as comfy as running your shellscripts locally, but it's better than scattering your scripts all over the place.

When trying sub, I realized that as SharedFolders cannot contain symlinks (at least this is the case when running vagrant on a windows host), sub will not work. In this blog post I would like to describe a setup which makes it possible to run sub within your vagrant box.

Donnerstag, 8. November 2012

symfony2, Behat, Mink & Zombie.js: Headless browser tests

I wanted to work with Behat for a while now. I remember hearing a talk by @everzet at the Symfony live Paris this year which got me interested in Behaviour Driven Development (BDD) and Behat. Now I finally came around and looked into the whole topic.

I decided to go straight to browser tests which also work for javascript heavy sites as this is a real pain for me right now, using symfony and the TestClient it provides which of course cannot evaluate any javascript.

Sonntag, 4. November 2012

Contributing isn't just about code

As some may know, I am a big fan of Open Source. One year ago I always thought about contributing to some OSS project but never did it. Sometimes I would donate a few dollars for a project I really liked.

Then I started using github, and everything got way easier. I started using github for my projects, then had a look at others. I did a very exiting first pull request on a minor error I found in the symfony documentation. I did a few more since then.

In this article, I would like to point out a few ways on how to contribute to open source projects. Turns out there are much more ways to contribute than fixing a bug in the code or adding a feature.