<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Articles about technology and the life of Jonathan H. Wage.</description><title>Jonathan H. Wage</title><generator>Tumblr (3.0; @jwage)</generator><link>http://jwage.com/</link><item><title>SunshinePHP Miami</title><description>&lt;p&gt;This past weekend I attended &lt;a href="http://sunshinephp.com/"&gt;SunshinePHP&lt;/a&gt; in beautiful Miami, Florida. I was lucky enough to get to speak about our experiences building &lt;a href="https://www.opensky.com"&gt;OpenSky&lt;/a&gt; with &lt;a href="http://www.symfony.com"&gt;Symfony&lt;/a&gt;. The weather was perfect and I got to learn some new things as well. Below you can find the slides from my presentation.&lt;/p&gt;

&lt;script async class="speakerdeck-embed" data-id="5d06e3e054690130178722000a1e8e84" data-ratio="1.2994923857868" src="//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;</description><link>http://jwage.com/post/42895003871</link><guid>http://jwage.com/post/42895003871</guid><pubDate>Mon, 11 Feb 2013 21:04:00 -0600</pubDate></item><item><title>imperfectwriting:

I went to the mall, and a little girl called...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_mc672df8Ek1r5estlo1_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;img src="http://25.media.tumblr.com/tumblr_mc672df8Ek1r5estlo2_500.jpg"/&gt;&lt;br/&gt; &lt;br/&gt;&lt;p&gt;&lt;a href="http://imperfectwriting.tumblr.com/post/33933007179/i-went-to-the-mall-and-a-little-girl-called-me-a" class="tumblr_blog"&gt;imperfectwriting&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I went to the mall, and a little girl called me a terrorist. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;My name is Ela.  I am seventeen years old.  I am not Muslim, but my friend told me about her friend being discriminated against for wearing a hijab.  So I decided to see the discrimination firsthand to get a better understanding of what Muslim women go through. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;My friend and I pinned scarves around our heads, and then we went to the mall.  Normally, vendors try to get us to buy things and ask us to sample a snack.  Clerks usually ask us if we need help, tell us about sales, and smile at us.  Not today.  People, including vendors, clerks, and other shoppers, wouldn’t look at us.  They didn’t talk to us.  They acted like we didn’t exist.  They didn’t want to be caught staring at us, so they didn’t look at all. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;And then, in one store, a girl (who looked about four years old) asked her mom if my friend and I were terrorists.  She wasn’t trying to be mean or anything.  I don’t even think she could have grasped the idea of prejudice.  However, her mother’s response is one I can never forgive or forget.  The mother hushed her child, glared at me, and then took her daughter by the hand and led her out of the store. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;All that because I put a scarf on my head.  Just like that, a mother taught her little girl that being Muslim was evil.  It didn’t matter that I was a nice person.  All that mattered was that I looked different.  That little girl may grow up and teach her children the same thing. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;This experiment gave me a huge wakeup call.  It lasted for only a few hours, so I can’t even begin to imagine how much prejudice Muslim girls go through every day.  It reminded me of something that many people know but rarely remember: the women in hijabs are people, just like all those women out there who aren’t Muslim. &lt;/p&gt;
&lt;p class="MsoNormal"&gt;People of Tumblr, please help me spread this message.  Treat Muslims, Jews, Christians, Buddhists, Hindus, Pagans, Taoists, etc., exactly the way you want to be treated, regardless of what they’re wearing or not wearing, no exceptions.  Reblog this.  Tell your friends.  I don’t know that the world will ever totally wipe out prejudice, but we can try, one blog at a time.  &lt;/p&gt;&lt;/blockquote&gt;</description><link>http://jwage.com/post/34051616750</link><guid>http://jwage.com/post/34051616750</guid><pubDate>Sun, 21 Oct 2012 15:35:06 -0500</pubDate></item><item><title>Global Community</title><description>&lt;p&gt;&lt;a href="http://kriswallsmith.net/post/32733578379/global-community" class="tumblr_blog"&gt;kriswallsmith&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I put out a call on Twitter the other day for people to add pins to this map if they have been thinking about Franya, me, and our children over the past couple of months. I’m blown away by the results. This is something we can all be proud of.&lt;/p&gt;

&lt;iframe width="688" height="459" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps/ms?msa=0&amp;amp;msid=215057856060671101536.0004cac694d4cf7ee96e8&amp;amp;ie=UTF8&amp;amp;t=m&amp;amp;ll=38.822591,-7.03125&amp;amp;spn=112.426297,241.523438&amp;amp;z=2&amp;amp;output=embed"&gt;&lt;/iframe&gt;

&lt;p&gt;If you haven’t added your pin, &lt;a href="https://maps.google.com/maps/ms?msa=0&amp;amp;msid=215057856060671101536.0004cac694d4cf7ee96e8&amp;amp;ie=UTF8&amp;amp;t=m&amp;amp;ll=38.822591,-7.03125&amp;amp;spn=112.426297,241.523438&amp;amp;z=2&amp;amp;source=embed"&gt;please do so&lt;/a&gt;. I’ll show this map to my kids some day.&lt;/p&gt;&lt;/blockquote&gt;</description><link>http://jwage.com/post/32921578673</link><guid>http://jwage.com/post/32921578673</guid><pubDate>Thu, 04 Oct 2012 23:09:06 -0500</pubDate></item><item><title>Doctrine Common Library</title><description>&lt;p&gt;&lt;a href="http://doctrine-project.org"&gt;Doctrine&lt;/a&gt; started as a library where all the internal components were coupled together. But as things have evolved the components have been decoupled and shared between the projects. This change also makes it possible for other people to use these pieces of Doctrine even if they don&amp;#8217;t use the ORM or any other project.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://github.com/doctrine/common/tree/master/lib/Doctrine/Common"&gt;Doctrine\Common&lt;/a&gt; namespace contains a few things like:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a href="https://github.com/doctrine/common/tree/master/lib/Doctrine/Common/Annotations"&gt;DocBlock Annotations Library&lt;/a&gt; - annotations library used by &lt;a href="http://symfony.com"&gt;Symfony&lt;/a&gt;, &lt;a href="http://drupal.org"&gt;Drupal&lt;/a&gt; and other popular PHP projects.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/doctrine/common/tree/master/lib/Doctrine/Common/Cache"&gt;Cache Drivers&lt;/a&gt; - APC, Memcache, etc. cache drivers.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/doctrine/common/tree/master/lib/Doctrine/Common/Persistence"&gt;Persistence&lt;/a&gt; - Shared base classes and interfaces across the object mappers.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Lexer.php"&gt;Lexer Parser&lt;/a&gt; - Base class for writing simple lexers, i.e. for creating small DSLs. I recently wrote a blog post about it &lt;a href="http://jwage.com/post/31623163785/writing-a-parser-in-php-with-the-help-of-doctrine"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;&lt;strong&gt;DocBlock AnnotationsLibrary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the annotations library you can parse information out of your DocBlocks in to PHP objects. The object mapper projects use this feature for specifying entity mapping information in the DocBlocks of your classes, properties and methods. Here is an example of what an entity looks like in the ORM:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;namespace MyProject\Entities;

use Doctrine\ORM\Mapping AS ORM;
use Symfony\Component\Validation\Constraints AS Assert;

/**
 * @ORM\Entity
 */
class User
{
    /**
     * @ORM\Id @ORM\Column @ORM\GeneratedValue
     */
    private $id;

    /**
     * @ORM\Column(type="string")
     * @Assert\NotEmpty
     * @Assert\Email
     */
    private $email;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Cache Drivers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The cache drivers provide a common interface to cache backends in PHP. Here are the supported drivers:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;ApcCache&lt;/li&gt;
&lt;li&gt;ArrayCache&lt;/li&gt;
&lt;li&gt;FileCache&lt;/li&gt;
&lt;li&gt;FilesystemCache&lt;/li&gt;
&lt;li&gt;MemcacheCache&lt;/li&gt;
&lt;li&gt;MemcachedCache&lt;/li&gt;
&lt;li&gt;PhpFileCache&lt;/li&gt;
&lt;li&gt;RedisCache&lt;/li&gt;
&lt;li&gt;WinCacheCache&lt;/li&gt;
&lt;li&gt;XcacheCache&lt;/li&gt;
&lt;li&gt;ZendDataCache&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The interface is very simple:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function fetch($id);
function contains($id);
function save($id, $data, $lifeTime = 0);
function delete($id);
function getStats();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Persistence Library&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The persistence interfaces are implemented by the object mapper libraries. They provide the common base classes and interfaces that a Doctrine object persistence library should implement, such as:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ObjectManager&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function find($className, $id);
function persist($object);
function remove($object);
function merge($object);
function clear($objectName = null);
function detach($object);
function refresh($object);
function flush();
function getRepository($className);
function getClassMetadata($className);
function getMetadataFactory();
function initializeObject($obj);
function contains($object);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;ObjectRepository&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function find($id);
function findAll();
function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
function findOneBy(array $criteria);
function getClassName();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;ClassMetadataFactory&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getAllMetadata();
function getMetadataFor($className);
function hasMetadataFor($className);
function setMetadataFor($className, $class);
function isTransient($className);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;ClassMetadata&lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getName();
function getIdentifier();
function getReflectionClass();
function isIdentifier($fieldName);
function hasField($fieldName);
function hasAssociation($fieldName);
function isSingleValuedAssociation($fieldName);
function isCollectionValuedAssociation($fieldName);
function getFieldNames();
function getIdentifierFieldNames();
function getAssociationNames();
function getTypeOfField($fieldName);
function getAssociationTargetClass($assocName);
function isAssociationInverseSide($assocName);
function getAssociationMappedByTargetField($assocName);
function getIdentifierValues($object);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;Doctrine\Common&lt;/code&gt; namespace contains lots more than I have mentioned here. So if you want to learn more check it out on &lt;a href="https://github.com/doctrine/common/tree/master/lib/Doctrine/Common"&gt;&lt;code&gt;GitHub&lt;/code&gt;&lt;/a&gt; or read the &lt;a href="http://docs.doctrine-project.org/projects/doctrine-common/en/latest/index.html"&gt;documentation&lt;/a&gt;. It is not that complete yet but it has some useful information.&lt;/p&gt;</description><link>http://jwage.com/post/32199136443</link><guid>http://jwage.com/post/32199136443</guid><pubDate>Mon, 24 Sep 2012 10:21:47 -0500</pubDate></item><item><title>Writing a parser in PHP with the help of Doctrine</title><description>&lt;p&gt;In the &lt;a href="http://doctrine-project.org"&gt;Doctrine&lt;/a&gt; project we have a SQL-like language called &lt;a href="http://doctrine-orm.readthedocs.org/en/2.0.x/reference/dql-doctrine-query-language.html"&gt;DQL&lt;/a&gt; for the ORM. In Doctrine1 the DQL language was not implemented with a true parser but in Doctrine2 the language was completely re-written with a true lexer parser. This lexer parser not only powers DQL but it also powers the &lt;a href="http://jwage.com/post/30490186668/doctrine-annotations-library"&gt;Annotations&lt;/a&gt; library in the &lt;a href="http://www.doctrine-project.org/projects/common.html"&gt;Common&lt;/a&gt; library.&lt;/p&gt;

&lt;p&gt;To write your own parser you just need to extend &lt;a href="https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Lexer.php"&gt;&lt;code&gt;Doctrine\Common\Lexer&lt;/code&gt;&lt;/a&gt; and implement the following three abstract methods. These methods define the &lt;a href="http://en.wikipedia.org/wiki/Lexical_analysis"&gt;lexical&lt;/a&gt; catchable and non-catchable patterns and a method for returning the type of a token and filtering the value if necessary.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/**
 * Lexical catchable patterns.
 *
 * @return array
 */
abstract protected function getCatchablePatterns();

/**
 * Lexical non-catchable patterns.
 *
 * @return array
 */
abstract protected function getNonCatchablePatterns();

/**
 * Retrieve token type. Also processes the token value if necessary.
 *
 * @param string $value
 * @return integer
 */
abstract protected function getType(&amp;amp;$value);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here is an example. The &lt;a href="https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/Lexer.php"&gt;&lt;code&gt;Doctrine\ORM\Query\Lexer&lt;/code&gt;&lt;/a&gt; implementation for DQL looks like the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;namespace Doctrine\ORM\Query;

class Lexer extends \Doctrine\Common\Lexer
{
    // All tokens that are not valid identifiers must be &amp;lt; 100
    const T_NONE                = 1;
    const T_INTEGER             = 2;
    const T_STRING              = 3;
    const T_INPUT_PARAMETER     = 4;
    const T_FLOAT               = 5;
    const T_CLOSE_PARENTHESIS   = 6;
    const T_OPEN_PARENTHESIS    = 7;
    const T_COMMA               = 8;
    const T_DIVIDE              = 9;
    const T_DOT                 = 10;
    const T_EQUALS              = 11;
    const T_GREATER_THAN        = 12;
    const T_LOWER_THAN          = 13;
    const T_MINUS               = 14;
    const T_MULTIPLY            = 15;
    const T_NEGATE              = 16;
    const T_PLUS                = 17;
    const T_OPEN_CURLY_BRACE    = 18;
    const T_CLOSE_CURLY_BRACE   = 19;

    // All tokens that are also identifiers should be &amp;gt;= 100
    const T_IDENTIFIER          = 100;
    const T_ALL                 = 101;
    const T_AND                 = 102;
    const T_ANY                 = 103;
    const T_AS                  = 104;
    const T_ASC                 = 105;
    const T_AVG                 = 106;
    const T_BETWEEN             = 107;
    const T_BOTH                = 108;
    const T_BY                  = 109;
    const T_CASE                = 110;
    const T_COALESCE            = 111;
    const T_COUNT               = 112;
    const T_DELETE              = 113;
    const T_DESC                = 114;
    const T_DISTINCT            = 115;
    const T_EMPTY               = 116;
    const T_ESCAPE              = 117;
    const T_EXISTS              = 118;
    const T_FALSE               = 119;
    const T_FROM                = 120;
    const T_GROUP               = 121;
    const T_HAVING              = 122;
    const T_IN                  = 123;
    const T_INDEX               = 124;
    const T_INNER               = 125;
    const T_INSTANCE            = 126;
    const T_IS                  = 127;
    const T_JOIN                = 128;
    const T_LEADING             = 129;
    const T_LEFT                = 130;
    const T_LIKE                = 131;
    const T_MAX                 = 132;
    const T_MEMBER              = 133;
    const T_MIN                 = 134;
    const T_NOT                 = 135;
    const T_NULL                = 136;
    const T_NULLIF              = 137;
    const T_OF                  = 138;
    const T_OR                  = 139;
    const T_ORDER               = 140;
    const T_OUTER               = 141;
    const T_SELECT              = 142;
    const T_SET                 = 143;
    const T_SIZE                = 144;
    const T_SOME                = 145;
    const T_SUM                 = 146;
    const T_TRAILING            = 147;
    const T_TRUE                = 148;
    const T_UPDATE              = 149;
    const T_WHEN                = 150;
    const T_WHERE               = 151;
    const T_WITH                = 153;
    const T_PARTIAL             = 154;
    const T_MOD                 = 155;

    /**
     * Creates a new query scanner object.
     *
     * @param string $input a query string
     */
    public function __construct($input)
    {
        $this-&amp;gt;setInput($input);
    }

    /**
     * @inheritdoc
     */
    protected function getCatchablePatterns()
    {
        return array(
            '[a-z_\\\][a-z0-9_\:\\\]*[a-z0-9_]{1}',
            '(?:[0-9]+(?:[\.][0-9]+)*)(?:e[+-]?[0-9]+)?',
            "'(?:[^']|'')*'",
            '\?[0-9]*|:[a-z]{1}[a-z0-9_]{0,}'
        );
    }

    /**
     * @inheritdoc
     */
    protected function getNonCatchablePatterns()
    {
        return array('\s+', '(.)');
    }

    /**
     * @inheritdoc
     */
    protected function getType(&amp;amp;$value)
    {
        $type = self::T_NONE;

        // Recognizing numeric values
        if (is_numeric($value)) {
            return (strpos($value, '.') !== false || stripos($value, 'e') !== false) 
                    ? self::T_FLOAT : self::T_INTEGER;
        }

        // Differentiate between quoted names, identifiers, input parameters and symbols
        if ($value[0] === "'") {
            $value = str_replace("''", "'", substr($value, 1, strlen($value) - 2));
            return self::T_STRING;
        } else if (ctype_alpha($value[0]) || $value[0] === '_') {
            $name = 'Doctrine\ORM\Query\Lexer::T_' . strtoupper($value);

            if (defined($name)) {
                $type = constant($name);

                if ($type &amp;gt; 100) {
                    return $type;
                }
            }

            return self::T_IDENTIFIER;
        } else if ($value[0] === '?' || $value[0] === ':') {
            return self::T_INPUT_PARAMETER;
        } else {
            switch ($value) {
                case '.': return self::T_DOT;
                case ',': return self::T_COMMA;
                case '(': return self::T_OPEN_PARENTHESIS;
                case ')': return self::T_CLOSE_PARENTHESIS;
                case '=': return self::T_EQUALS;
                case '&amp;gt;': return self::T_GREATER_THAN;
                case '&amp;lt;': return self::T_LOWER_THAN;
                case '+': return self::T_PLUS;
                case '-': return self::T_MINUS;
                case '*': return self::T_MULTIPLY;
                case '/': return self::T_DIVIDE;
                case '!': return self::T_NEGATE;
                case '{': return self::T_OPEN_CURLY_BRACE;
                case '}': return self::T_CLOSE_CURLY_BRACE;
                default:
                    // Do nothing
                    break;
            }
        }

        return $type;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;Lexer&lt;/code&gt; parser is responsible for giving you an API to walk across a string and analyze the type, value and position of each token in the string. The low level API of the lexer is pretty simple:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;setInput($input)&lt;/strong&gt; - Sets the input data to be tokenized. The Lexer is immediately reset and the new input tokenized.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;reset()&lt;/strong&gt; - Resets the lexer.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;resetPeek()&lt;/strong&gt; - Resets the peek pointer to 0.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;resetPosition($position = 0)&lt;/strong&gt; - Resets the lexer position on the input to the given position.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;isNextToken($token)&lt;/strong&gt; - Checks whether a given token matches the current lookahead.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;isNextTokenAny(array $tokens)&lt;/strong&gt; - Checks whether any of the given tokens matches the current lookahead.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;moveNext()&lt;/strong&gt; - Moves to the next token in the input string.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;skipUntil($type)&lt;/strong&gt; - Tells the lexer to skip input tokens until it sees a token with the given value.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;isA($value, $token)&lt;/strong&gt; - Checks if given value is identical to the given token.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;peek()&lt;/strong&gt; - Moves the lookahead token forward.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;glimpse()&lt;/strong&gt; - Peeks at the next token, returns it and immediately resets the peek.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Put it all together and this is what you get. This is what the Doctrine ORM DQL parser implementation looks like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Parser
{
    private $lexer;

    public function __construct($dql)
    {
        $this-&amp;gt;lexer = new Lexer();
        $this-&amp;gt;lexer-&amp;gt;setInput($dql);
    }

    // ...

    public function getAST()
    {
        // Parse &amp;amp; build AST
        $AST = $this-&amp;gt;QueryLanguage();

        // ...

        return $AST;
    }

    public function QueryLanguage()
    {
        $this-&amp;gt;lexer-&amp;gt;moveNext();

        switch ($this-&amp;gt;lexer-&amp;gt;lookahead['type']) {
            case Lexer::T_SELECT:
                $statement = $this-&amp;gt;SelectStatement();
                break;
            case Lexer::T_UPDATE:
                $statement = $this-&amp;gt;UpdateStatement();
                break;
            case Lexer::T_DELETE:
                $statement = $this-&amp;gt;DeleteStatement();
                break;
            default:
                $this-&amp;gt;syntaxError('SELECT, UPDATE or DELETE');
                break;
        }

        // Check for end of string
        if ($this-&amp;gt;lexer-&amp;gt;lookahead !== null) {
            $this-&amp;gt;syntaxError('end of string');
        }

        return $statement;
    }

    // ...
}

$parser = new Parser('SELECT u FROM User u');
$AST = $parser-&amp;gt;getAST(); // returns \Doctrine\ORM\Query\AST\SelectStatement
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What is an AST? AST stands for &lt;a href="http://en.wikipedia.org/wiki/Abstract_syntax_tree"&gt;Abstract syntax tree&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;In computer science, an abstract syntax tree (AST), or just syntax tree, is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code.&lt;/blockquote&gt;

&lt;p&gt;Now the AST is used to transform the DQL query in to portable SQL for whatever relational database you are using! Cool!&lt;/p&gt;</description><link>http://jwage.com/post/31623163785</link><guid>http://jwage.com/post/31623163785</guid><pubDate>Sat, 15 Sep 2012 19:37:00 -0500</pubDate></item><item><title>“The Advanced Research Projects Agency Network (ARPANET)...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_maeynrag1E1qa7z0xo1_500.png"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;“The Advanced Research Projects Agency Network (ARPANET) was the world’s first operational packet switching network and the progenitor of what was to become the global Internet. The network was initially funded by the Advanced Research Projects Agency (ARPA, later DARPA) within the U.S. Department of Defense for use by its projects at universities and research laboratories in the US. The packet switching of the ARPANET was based on designs by British scientist Donald Davies and Lawrence Roberts of the Lincoln Laboratory.”&lt;/p&gt;</description><link>http://jwage.com/post/31617527993</link><guid>http://jwage.com/post/31617527993</guid><pubDate>Sat, 15 Sep 2012 18:02:15 -0500</pubDate></item><item><title>Tumblr Code Syntax Highlighting</title><description>&lt;p&gt;Finally got around to adding code syntax highlighting to my tumblr blog. Thanks to this &lt;a href="http://snippets-of-code.tumblr.com/post/6027484416/adding-syntax-highlighting-into-tumblr"&gt;post&lt;/a&gt; it was really easy!&lt;/p&gt;

&lt;p&gt;In your head tag add the following javascript:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!-- For Syntax Highlighting --&amp;gt;
&amp;lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;link rel="stylesheet" type="text/css" href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css"&amp;gt;&amp;lt;/link&amp;gt;  
&amp;lt;script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"&amp;gt;&amp;lt;/script&amp;gt;  
&amp;lt;script&amp;gt;
    function styleCode() {
        if (typeof disableStyleCode != 'undefined') { return; }

        var a = false;

        $('pre').each(function() {
            if (!$(this).hasClass('prettyprint')) {
                $(this).addClass('prettyprint');
                a = true;
            }
        });

        if (a) { prettyPrint(); } 
    }

    $(function() {styleCode();});
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then in your add this css:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/* Pretty printing styles. Used with prettify.js. */
/* Vim sunburst theme by David Leibovic */

pre .str, code .str { color: #65B042; } /* string  - green */
pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */
pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */
pre .typ, code .typ { color: #89bdff; } /* type - light blue */
pre .lit, code .lit { color: #3387CC; } /* literal - blue */
pre .pun, code .pun { color: #fff; } /* punctuation - white */
pre .pln, code .pln { color: #fff; } /* plaintext - white */
pre .tag, code .tag { color: #89bdff; } /* html/xml tag    - light blue */
pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name  - khaki */
pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */
pre .dec, code .dec { color: #3387CC; } /* decimal - blue */

pre.prettyprint, code.prettyprint {
        background-color: #000;
        -moz-border-radius: 8px;
        -webkit-border-radius: 8px;
        -o-border-radius: 8px;
        -ms-border-radius: 8px;
        -khtml-border-radius: 8px;
        border-radius: 8px;
}

pre.prettyprint {
        width: 95%;
        margin: 1em auto;
        padding: 1em !important;
        white-space: pre-wrap;
}

/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { }

@media print {
  pre .str, code .str { color: #060; }
  pre .kwd, code .kwd { color: #006; font-weight: bold; }
  pre .com, code .com { color: #600; font-style: italic; }
  pre .typ, code .typ { color: #404; font-weight: bold; }
  pre .lit, code .lit { color: #044; }
  pre .pun, code .pun { color: #440; }
  pre .pln, code .pln { color: #000; }
  pre .tag, code .tag { color: #006; font-weight: bold; }
  pre .atn, code .atn { color: #404; }
  pre .atv, code .atv { color: #060; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That is it. I didn&amp;#8217;t think it would be that easy!&lt;/p&gt;

&lt;p&gt;You can find more themes &lt;a href="http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html"&gt;here&lt;/a&gt;.&lt;/p&gt;</description><link>http://jwage.com/post/31305747748</link><guid>http://jwage.com/post/31305747748</guid><pubDate>Mon, 10 Sep 2012 19:58:00 -0500</pubDate><category>articles</category></item><item><title>Ruler: A simple stateless production rules engine for PHP 5.3+</title><description>&lt;p&gt;&lt;strong&gt;What is ruler?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/bobthecow/ruler"&gt;Ruler&lt;/a&gt; is a simple stateless production rules engine for PHP 5.3+ written by &lt;a href="http://twitter.com/bobthecow"&gt;Justin Hileman (@bobthecow)&lt;/a&gt;. Justin was previously employed at &lt;a href="https://opensky.com"&gt;OpenSky&lt;/a&gt; but these days you will find him hacking on a new startup named &lt;a href="https://twitter.com/presentate"&gt;@presentate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is a rules engine?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From &lt;a href="http://martinfowler.com/bliki/RulesEngine.html"&gt;martinfowler.com&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;A rules engine is all about providing an alternative computational model. Instead of the usual imperative model, commands in sequence with conditionals and loops, it provides a list of production rules. Each rule has a condition and an action - simplistically you can think of it as a bunch of if-then statements.&lt;/blockquote&gt;

&lt;p&gt;From &lt;a href="http://en.wikipedia.org/wiki/Business_rules_engine"&gt;wikipedia&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;A business rules engine is a software system that executes one or more business rules in a runtime production environment. The rules might come from legal regulation (&amp;#8220;An employee can be fired for any reason or no reason but not for an illegal reason&amp;#8221;), company policy (&amp;#8220;All customers that spend more than $100 at one time will receive a 10% discount&amp;#8221;), or other sources. A business rule system enables these company policies and other operational decisions to be defined, tested, executed and maintained separately from application code.&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;What does Ruler usage look like?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ruler has a nice and convenient DSL that is provided by &lt;code&gt;RuleBuilder&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$rb = new RuleBuilder;
$rule = $rb-&amp;gt;create(
    $rb-&amp;gt;logicalAnd(
        $rb['minAge']-&amp;gt;greaterThan($rb['age']),
        $rb['maxAge']-&amp;gt;lessThan($rb['age'])
    ),
    function() {
        echo 'Congratulations! You are between the ages of 18 and 25!';
    }
);

$context = new Context(array(
    'minAge' =&amp;gt; 18,
    'maxAge' =&amp;gt; 25,
    'age' =&amp;gt; function() {
        return 20;
    },
));

$rule-&amp;gt;execute($context); // "Congratulations! You are between the ages of 18 and 25!"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The full API is quite simple:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// These are Variables. They'll be replaced by terminal values during Rule evaluation.

$a = $rb['a'];
$b = $rb['b'];

// Here are bunch of Propositions. They're not too useful by themselves, but they
// are the building blocks of Rules, so you'll need 'em in a bit.

$a-&amp;gt;greaterThan($b);          // true if $a &amp;gt; $b
$a-&amp;gt;greaterThanOrEqualTo($b); // true if $a &amp;gt;= $b
$a-&amp;gt;lessThan($b);             // true if $a &amp;lt; $b
$a-&amp;gt;lessThanOrEqualTo($b);    // true if $a &amp;lt;= $b
$a-&amp;gt;equalTo($b);              // true if $a == $b
$a-&amp;gt;notEqualTo($b);           // true if $a != $b
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can combine things to create more complex rules:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// Create a Rule with an $a == $b condition
$aEqualsB = $rb-&amp;gt;create($a-&amp;gt;equalTo($b));

// Create another Rule with an $a != $b condition
$aDoesNotEqualB = $rb-&amp;gt;create($a-&amp;gt;notEqualTo($b));

// Now combine them for a tautology!
// (Because Rules are also Propositions, they can be combined to make MEGARULES)
$eitherOne = $rb-&amp;gt;create($rb-&amp;gt;logicalOr($aEqualsB, $aDoesNotEqualB));

// Just to mix things up, we'll populate our evaluation context with completely
// random values...
$context = new Context(array(
    'a' =&amp;gt; rand(),
    'b' =&amp;gt; rand(),
));

// Hint: this is always true!
$eitherOne-&amp;gt;evaluate($context);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;More complex examples:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$rb-&amp;gt;logicalNot($aEqualsB);                  // The same as $aDoesNotEqualB :)
$rb-&amp;gt;logicalAnd($aEqualsB, $aDoesNotEqualB); // True if both conditions are true
$rb-&amp;gt;logicalOr($aEqualsB, $aDoesNotEqualB);  // True if either condition is true
$rb-&amp;gt;logicalXor($aEqualsB, $aDoesNotEqualB); // True if only one condition is true
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Full Examples&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Check if user is logged in:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$context = new Context(array('username', function() {
    return isset($_SESSION['username']) ? $_SESSION['username'] : null;
}));

$userIsLoggedIn = $rb-&amp;gt;create($rb['username']-&amp;gt;notEqualTo(null));

if ($userIsLoggedIn-&amp;gt;evaluate($context)) {
    // Do something special for logged in users!
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If a Rule has an action, you can execute() it directly and save yourself a couple of lines of code.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$hiJustin = $rb-&amp;gt;create(
    $rb['userName']-&amp;gt;equalTo('bobthecow'),
    function() {
        echo "Hi, Justin!";
    }
);

$hiJustin-&amp;gt;execute($context);  // "Hi, Justin!"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;What does &lt;a href="https://opensky.com"&gt;OpenSky&lt;/a&gt; use Ruler for?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://opensky.com"&gt;OpenSky&lt;/a&gt; makes heavy use of Ruler. Below is a list of some of the conditions we have available in our application:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;p&gt;Joins OpenSky&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Is Facebook Connected&lt;/li&gt;
&lt;li&gt;Number of friends is &amp;gt;= n&lt;/li&gt;
&lt;li&gt;Number of friends is &amp;lt;= n&lt;/li&gt;
&lt;li&gt;With certain origination parameters existing in URL&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Makes a Purchase&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Within x days of joining&lt;/li&gt;
&lt;li&gt;Is first purchase&lt;/li&gt;
&lt;li&gt;Order amount is &amp;gt;= n&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Loves an offer&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Is first love of the day&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Visits OpenSky&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Is Facebook Connected&lt;/li&gt;
&lt;li&gt;Number of friends is &amp;gt;= n&lt;/li&gt;
&lt;li&gt;Number of friends is &amp;lt;= n&lt;/li&gt;
&lt;li&gt;Users points are &amp;gt;= n&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;These are just some of the conditions we have available. Our application is setup in a way that we can easily create new rules via a backend GUI. We can mix and match conditions and rewards. Some of the rewards we have available are:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Issue n points&lt;/li&gt;
&lt;li&gt;New member level&lt;/li&gt;
&lt;li&gt;Credit&lt;/li&gt;
&lt;li&gt;Free shipping&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;The benefit of this abstract setup is it allows us to combine different conditions, tweak the parameters of the conditions and issue rewards depending on the outcome of the condition all without requiring code changes and a deploy. You can imagine our business and marketing teams love this because they can change things all day long and without having to bother the tech team.&lt;/p&gt;</description><link>http://jwage.com/post/31292541379</link><guid>http://jwage.com/post/31292541379</guid><pubDate>Mon, 10 Sep 2012 17:01:24 -0500</pubDate></item><item><title>Audit of NY Fed Reveals Technocrat’s Creation and Cover-Up of Global Financial Crash</title><description>&lt;a href="http://theintelhub.com/2012/09/02/audit-of-the-federal-reserve-reveals-16-trillion-in-secret-bailouts/"&gt;Audit of NY Fed Reveals Technocrat’s Creation and Cover-Up of Global Financial Crash&lt;/a&gt;: &lt;p&gt;“As a result of this audit, we now know that the Federal Reserve provided more than $16 trillion in total financial assistance to some of the largest financial institutions and corporations in the United States and throughout the world. This is a clear case of socialism for the rich and rugged, you’re-on-your-own individualism for everyone else.”&lt;/p&gt;

&lt;p&gt;“A source in the Deutsche Bank &lt;a href="http://occupycorporatism.com/government-silently-positions-for-martial-law-as-financial-collapse-arrives-in-america/"&gt;explained&lt;/a&gt; that in 2008 our financial and monetary system completely collapsed and since that time the banking cartels have been “propping up the system” to make it appear as if everything was fine.”&lt;/p&gt;</description><link>http://jwage.com/post/31205802819</link><guid>http://jwage.com/post/31205802819</guid><pubDate>Sun, 09 Sep 2012 11:46:27 -0500</pubDate></item><item><title>Doctrine DBAL: PHP Database Abstraction Layer</title><description>&lt;p&gt;Most people think ORM when they hear the name &lt;a href="http://doctrine-project.org"&gt;Doctrine&lt;/a&gt;, but what most people don&amp;#8217;t know, or forget, is that Doctrine is built on top of a very powerful Database Abstraction Layer that has been under development for over a decade. It&amp;#8217;s history can be traced back to 1999 in a library named Metabase which was forked to create PEAR MDB, then MDB2, Zend_DB and finally Doctrine1. In Doctrine2 the DBAL was completely decoupled from the ORM, components re-written for PHP 5.3 and made a standalone library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does it support?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Connection Abstraction&lt;/li&gt;
&lt;li&gt;Platform Abstraction&lt;/li&gt;
&lt;li&gt;Data Type Abstraction&lt;/li&gt;
&lt;li&gt;SQL Query Builder&lt;/li&gt;
&lt;li&gt;Transactions&lt;/li&gt;
&lt;li&gt;Schema Manager&lt;/li&gt;
&lt;li&gt;Schema Representation&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;li&gt;Prepared Statements&lt;/li&gt;
&lt;li&gt;Sharding&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;Much more&amp;#8230;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Creating connections is easy. It can be done by using the &lt;code&gt;DriverManager&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?php
$config = new \Doctrine\DBAL\Configuration();
//..
$connectionParams = array(
    'dbname' =&amp;gt; 'mydb',
    'user' =&amp;gt; 'user',
    'password' =&amp;gt; 'secret',
    'host' =&amp;gt; 'localhost',
    'driver' =&amp;gt; 'pdo_mysql',
);
$conn = DriverManager::getConnection($connectionParams, $config);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;DriverManager&lt;/code&gt; returns an instance of &lt;code&gt;Doctrine\DBAL\Connection&lt;/code&gt; which is a wrapper around the underlying driver connection (which is often a PDO instance).&lt;/p&gt;

&lt;p&gt;By default we offer built-in support for many popular relational databases supported by PHP, such as:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;pdo_mysql&lt;/li&gt;
&lt;li&gt;pdo_sqlite&lt;/li&gt;
&lt;li&gt;pdo_pgsql&lt;/li&gt;
&lt;li&gt;pdo_oci&lt;/li&gt;
&lt;li&gt;pdo_sqlsrv&lt;/li&gt;
&lt;li&gt;oci8&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;If you need to do something custom, don&amp;#8217;t worry everything is abstracted so you can write your own drivers to communicate with any relational database you want. For example, recently work has &lt;a href="https://github.com/doctrine/dbal/pull/191"&gt;begun&lt;/a&gt; on integrating &lt;a href="http://www.akiban.com/"&gt;Akiban SQL Server&lt;/a&gt; with Doctrine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to work with your data&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Doctrine\DBAL\Connection&lt;/code&gt; object provides a convenient interface for retrieving and manipulating your data. You will find it is familiar and resembles PDO.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$sql = "SELECT * FROM articles";
$stmt = $conn-&amp;gt;query($sql);

while ($row = $stmt-&amp;gt;fetch()) {
    echo $row['headline'];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To send an update and return the affected rows you can do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$count = $conn-&amp;gt;executeUpdate('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It also provide a convenient &lt;code&gt;insert()&lt;/code&gt; and &lt;code&gt;update()&lt;/code&gt; method to make inserting and updating data easier:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$conn-&amp;gt;insert('user', array('username' =&amp;gt; 'jwage'));
// INSERT INTO user (username) VALUES (?) (jwage)

$conn-&amp;gt;update('user', array('username' =&amp;gt; 'jwage'), array('id' =&amp;gt; 1));
// UPDATE user (username) VALUES (?) WHERE id = ? (jwage, 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Fluent Query Builder Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you need a programatic way to build your SQL queries you can do so using the &lt;code&gt;QueryBuilder&lt;/code&gt;. The &lt;code&gt;QueryBuilder&lt;/code&gt; object has methods to add parts to a SQL statement. The API is roughly the same as that of the DQL Query Builder.&lt;/p&gt;

&lt;p&gt;To create a new query builder you can do so from your connection:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb = $conn-&amp;gt;createQueryBuilder();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you can start to build your query:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb
    -&amp;gt;select('u')
    -&amp;gt;from('users', 'u')
    -&amp;gt;where($qb-&amp;gt;expr()-&amp;gt;eq('u.id', 1));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can use named parameters:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb = $conn-&amp;gt;createQueryBuilder()
    -&amp;gt;select('u')
    -&amp;gt;from('users', 'u')
    -&amp;gt;where('u.id = :user_id')
    -&amp;gt;setParameter(':user_id', 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It can handle joins:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb = $conn-&amp;gt;createQueryBuilder()
    -&amp;gt;select('u.id')
    -&amp;gt;addSelect('p.id')
    -&amp;gt;from('users', 'u')
    -&amp;gt;leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Updates and deletes are no problem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb = $conn-&amp;gt;createQueryBuilder()
    -&amp;gt;update('users', 'u')
    -&amp;gt;set('u.password', md5('password'))
    -&amp;gt;where('u.id = ?');

$qb = $conn-&amp;gt;createQueryBuilder()
    -&amp;gt;delete('users', 'u')
    -&amp;gt;where('u.id = :user_id');
    -&amp;gt;setParameter(':user_id', 1);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you want to inspect the SQL resulting from a &lt;code&gt;QueryBuilder&lt;/code&gt;, that is no problem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$qb = $em-&amp;gt;createQueryBuilder()
    -&amp;gt;select('u')
    -&amp;gt;from('User', 'u')
echo $qb-&amp;gt;getSQL(); // SELECT u FROM User u
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The interface has much more and handles most everything you can do when writing SQL manually. It instantly makes your queries reusable, extensible and easier to manage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Managing your Schema&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of my favorite features of the Doctrine 2.x series is the schema management feature. A &lt;code&gt;SchemaManager&lt;/code&gt; instance helps you with the abstraction of the generation of SQL assets such as Tables, Sequences, Foreign Keys and Indexes.&lt;/p&gt;

&lt;p&gt;To get a &lt;code&gt;SchemaManager&lt;/code&gt; you can use the &lt;code&gt;getSchemaManager()&lt;/code&gt; method on your connection:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$sm = $conn-&amp;gt;getSchemaManager();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you can introspect your database with the API:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$databases = $sm-&amp;gt;listDatabases();
$sequences = $sm-&amp;gt;listSequences('dbname');

foreach ($sequences as $sequence) {
    echo $sequence-&amp;gt;getName() . "\n";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;List the columns in a table:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$columns = $sm-&amp;gt;listTableColumns('user');
foreach ($columns as $column) {
    echo $column-&amp;gt;getName() . ': ' . $column-&amp;gt;getType() . "\n";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can even issue DDL statements from the &lt;code&gt;SchemaManager&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$table-&amp;gt;addColumn('email_address', 'string');
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Schema Representation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For a complete representation of the current database you can use the createSchema() method which returns an instance of &lt;code&gt;Doctrine\DBAL\Schema\Schema&lt;/code&gt;, which you can use in conjunction with the &lt;code&gt;SchemaTool&lt;/code&gt; or &lt;code&gt;SchemaComparator&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$fromSchema = $sm-&amp;gt;createSchema();

$toSchema = clone $fromSchema;
$toSchema-&amp;gt;dropTable('user');
$sql = $fromSchema-&amp;gt;getMigrateToSql($toSchema, $conn-&amp;gt;getDatabasePlatform());

print_r($sql);

/*
array(
  0 =&amp;gt; 'DROP TABLE user'
)
*/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;SchemaManager&lt;/code&gt; allows for some nice functionality to be built for the &lt;a href="http://www.doctrine-project.org/projects/orm.html"&gt;Doctrine ORM&lt;/a&gt; project for reverse engineering databases in to Doctrine mapping files. This makes it easy to get started using the ORM with legacy databases. It is also used in the &lt;a href="http://www.doctrine-project.org/projects/migrations.html"&gt;Doctrine Migrations&lt;/a&gt; project to allow you to manage versions of your schema and easily deploy changes to production databases in a controlled and versioned fashion.&lt;/p&gt;

&lt;p&gt;The next time you need to access a relational database in PHP, whether it be in a proprietary or open source application, consider &lt;a href="http://doctrine-project.org"&gt;Doctrine&lt;/a&gt;. Take advantage of our community and team of developers so you can focus on your core competency and really excel in it.&lt;/p&gt;</description><link>http://jwage.com/post/31080076112</link><guid>http://jwage.com/post/31080076112</guid><pubDate>Fri, 07 Sep 2012 17:18:00 -0500</pubDate><category>doctrine</category><category>php</category><category>rdbms</category><category>open source</category></item><item><title>Deploying OpenSky with Fabric</title><description>&lt;p&gt;At &lt;a href="http://opensky.com"&gt;OpenSky&lt;/a&gt; we use &lt;a href="http://docs.fabfile.org/en/1.4.3/index.html"&gt;Fabric&lt;/a&gt; to deploy new versions of software to our servers. We deploy dozens of times a day to our testing environments, and do daily deploys to production.&lt;/p&gt;

&lt;p&gt;Our production web nodes are split in to two groups, &lt;strong&gt;group1&lt;/strong&gt; and &lt;strong&gt;group2&lt;/strong&gt;. It is setup that way so we can easily pull out a group of web nodes from the load balancer for maintenance without disrupting the site.&lt;/p&gt;

&lt;p&gt;In this post I will take you through a hotfix scenario and the steps we take to deploy to production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Scenario&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine we just released &lt;strong&gt;v3.0.0&lt;/strong&gt; to production and we discover a critical bug that must be hotfixed.&lt;/p&gt;

&lt;p&gt;First thing we need to do is create a hotfix branch. We use &lt;a href="https://github.com/nvie/gitflow"&gt;gitflow&lt;/a&gt; to assist with streamlining this process. I won&amp;#8217;t talk too much about it here so I will assume you already know what it is.&lt;/p&gt;

&lt;p&gt;Create the hotfix:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git flow hotfix start 3.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Modify the &lt;strong&gt;opensky/config/version.ini&lt;/strong&gt; file and bump the version number:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[parameters]
opensky.version = 3.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add the changed file, commit it and push up the hotfix:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git add opensky/config/version.ini
git commit -m"Bump version to 3.0.1"
git push origin hotfix/3.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Another developer who is responsible for fixing the bug will create a new branch based off of &lt;strong&gt;hotfix/3.0.1&lt;/strong&gt; where the fix will be made:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git fetch
git checkout -b fix-the-bug origin/hotfix/3.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The developer makes some changes and pushes up the new branch:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git add src/changed/file
git commit -m"Fixed nasty bug"
git push origin fix-the-bug
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We use &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; pull requests for all of our code changes to be as transparent as possible and maintain a high level of peer code review. The developer would create a pull request for the &lt;strong&gt;fix-the-bug&lt;/strong&gt; branch and ask for a team mate to review. We have a special bot named &lt;strong&gt;@pr-nightmare&lt;/strong&gt; that runs our tests against the branch to ensure stability before it is merged. Once the branch gets a +1 from @pr-nightmare the team mate can merge the branch in to &lt;strong&gt;hotfix/3.0.1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once it is merged we are ready to finish the hotfix:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git pull origin hotfix/3.0.1
git flow hotfix finish 3.0.1
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above command will merge &lt;strong&gt;hotfix/3.0.1&lt;/strong&gt; in to &lt;strong&gt;production&lt;/strong&gt; and &lt;strong&gt;develop&lt;/strong&gt; and create a new tag named &lt;strong&gt;v3.0.1&lt;/strong&gt; that can be deployed to production.&lt;/p&gt;

&lt;p&gt;Now push the finished hotfix up to git:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git push origin develop
git push origin production
git push --tags
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We are all set and ready to go to production with the &lt;strong&gt;v3.0.1&lt;/strong&gt; tag using fabric.&lt;/p&gt;

&lt;p&gt;First thing we need to do is pull out a group of nodes from the load balancer so that we can deploy &lt;strong&gt;v3.0.1&lt;/strong&gt; to it. We will pull out &lt;strong&gt;group1&lt;/strong&gt; and leave &lt;strong&gt;group2&lt;/strong&gt; live:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fab prod proxy.group2
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now &lt;strong&gt;group2&lt;/strong&gt; is live and &lt;strong&gt;group1&lt;/strong&gt; is not receiving any traffic so we can deploy to it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fab prod:out deploy:stable
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above command automatically determines what the latest stable tag to deploy is. In this case it will deploy &lt;strong&gt;v3.0.1&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Once that is done we can flip &lt;strong&gt;group1&lt;/strong&gt; live and pull out &lt;strong&gt;group2&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fab prod proxy.flip
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now &lt;strong&gt;group1&lt;/strong&gt; is live with the hotfix and &lt;strong&gt;group2&lt;/strong&gt; is out of rotation. To finish we run the same command as before and deploy the hotfix to &lt;strong&gt;group2&lt;/strong&gt; as well:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fab prod:out deploy:stable
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can push both groups live again and we are done:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;fab prod proxy.all
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The process could be even more streamlined and we&amp;#8217;re actively working to remove steps and make it even easier to deploy to production!&lt;/p&gt;</description><link>http://jwage.com/post/31049115791</link><guid>http://jwage.com/post/31049115791</guid><pubDate>Fri, 07 Sep 2012 04:01:00 -0500</pubDate></item><item><title>Portland is awesome. So easy to get around the city and the...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m9vw8b8MNs1qa7z0xo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Portland is awesome. So easy to get around the city and the weather is fantastic this morning!&lt;/p&gt;</description><link>http://jwage.com/post/30936505525</link><guid>http://jwage.com/post/30936505525</guid><pubDate>Wed, 05 Sep 2012 10:55:23 -0500</pubDate></item><item><title>TripCase is a pretty nice iPhone app for viewing flight info...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m9uf1n3JR91qa7z0xo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;TripCase is a pretty nice iPhone app for viewing flight info easily.&lt;/p&gt;</description><link>http://jwage.com/post/30887050504</link><guid>http://jwage.com/post/30887050504</guid><pubDate>Tue, 04 Sep 2012 15:46:35 -0500</pubDate></item><item><title>Github Archive</title><description>&lt;a href="http://www.githubarchive.org/"&gt;Github Archive&lt;/a&gt;: &lt;p&gt;This is really awesome!&lt;/p&gt;

&lt;p&gt;“Open-source developers all over the world are working on millions of projects: writing code &amp; documentation, fixing &amp; submitting bugs, and so forth. GitHub Archive is a project to record the public GitHub timeline, archive it, and make it easily accessible for further analysis.”&lt;/p&gt;</description><link>http://jwage.com/post/30879604060</link><guid>http://jwage.com/post/30879604060</guid><pubDate>Tue, 04 Sep 2012 13:30:40 -0500</pubDate></item><item><title>“Considering we are currently living through Great...</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m9t56onltW1qa7z0xo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;“Considering we are currently living through Great Depression 2.0, it’s important to consider why the first one happened. Well-meaning but mistaken people often say that the “laissez-faire” policies of Hoover (1929-1933) led to the Great Depression, and that the spending policies of FDR got us out of it. The reality is that Hoover began ramping up government spending rapidly, this caused the Depression, then FDR continued this, causing it to last a decade.&lt;/p&gt;

&lt;p&gt;The depression didn’t truly end until Eisenhower brought the troops home and radically cut military and domestic spending, after which time we had a short recession, then a boom.&lt;/p&gt;

&lt;p&gt;This chart also shows what happens when spending is cut. Calvin Coolidge, who oversaw a period when the US avoided all military engagements, held down government spending, and didn’t bail out the banks when there was a crash, was president during the period on the chart with reduced spending, which coincides with the “Roaring 20s,” a period known for peace and prosperity in America.” - Barry Donegan&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.facebook.com/photo.php?fbid=10151051626652196&amp;set=a.69645422195.76815.511347195&amp;type=1"&gt;http://www.facebook.com/photo.php?fbid=10151051626652196&amp;set=a.69645422195.76815.511347195&amp;type=1&lt;/a&gt;&lt;/p&gt;</description><link>http://jwage.com/post/30871433286</link><guid>http://jwage.com/post/30871433286</guid><pubDate>Tue, 04 Sep 2012 10:07:17 -0500</pubDate></item><item><title>Star Wars Lightsaber Ice Pop Maker</title><description>&lt;a href="http://www.thinkgeek.com/product/eea5/?cpg=fbl_eea5"&gt;Star Wars Lightsaber Ice Pop Maker&lt;/a&gt;: &lt;p&gt;Before Blue Milk, before Ewok Jerky, before that frog thing that Jabba eats, before even Yoda’s stew, the main food of the Jedi was ice pops!&lt;/p&gt;</description><link>http://jwage.com/post/30864982662</link><guid>http://jwage.com/post/30864982662</guid><pubDate>Tue, 04 Sep 2012 06:45:20 -0500</pubDate></item><item><title>"What’s on my mind? It is imperative that this country reach a moral conclusion that the growth..."</title><description>“What’s on my mind? It is imperative that this country reach a moral conclusion that the growth of the entitlement state over the past half-century has undermined the sturdy self-reliance that has long characterized most Americans, replacing it with a culture of dependence that threatens the American experiment!”&lt;br/&gt;&lt;br/&gt; - &lt;em&gt;Lisa Stevens (my mother in law)&lt;/em&gt;</description><link>http://jwage.com/post/30860129856</link><guid>http://jwage.com/post/30860129856</guid><pubDate>Tue, 04 Sep 2012 03:22:24 -0500</pubDate></item><item><title>In Chicago for about 5 minutes :)</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_m9uf1bkYQu1qa7z0xo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;In Chicago for about 5 minutes :)&lt;/p&gt;</description><link>http://jwage.com/post/30887038039</link><guid>http://jwage.com/post/30887038039</guid><pubDate>Mon, 03 Sep 2012 22:27:36 -0500</pubDate></item><item><title>In Chicago for about 5 minutes :)</title><description>&lt;img src="http://24.media.tumblr.com/tumblr_m9sp4wZ75p1qa7z0xo1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;In Chicago for about 5 minutes :)&lt;/p&gt;</description><link>http://jwage.com/post/30828812012</link><guid>http://jwage.com/post/30828812012</guid><pubDate>Mon, 03 Sep 2012 17:29:20 -0500</pubDate></item><item><title>Verified Warnings From Former U.S. Presidents About the “Invisible Government” Running the U.S. With “No Allegiance To the People” </title><description>&lt;a href="http://beforeitsnews.com/conspiracy-theories/2012/08/verified-warnings-from-former-u-s-presidents-about-the-invisible-government-running-the-u-s-with-no-allegiance-to-the-people-2444404.html"&gt;Verified Warnings From Former U.S. Presidents About the “Invisible Government” Running the U.S. With “No Allegiance To the People” &lt;/a&gt;: &lt;p&gt;“Past presidents of the United States and other high profile political leaders have repeatedly issued warnings over the last 214 years that the U.S. government is under the control of an “invisible government owing no allegiance and acknowledging no responsibility to the people.”&lt;/p&gt;

&lt;p&gt;According to our past presidents (and other high profile political leaders), an invisible government has been in control of the U.S. “ever since the days of Andrew Jackson” (since at least 1836) and is “incredibly evil in intent.” They “virtually run the United States government for their own selfish purposes. They practically control both parties… It operates under cover of a self-created screen [and] seizes our executive officers, legislative bodies, schools, courts, newspapers and every agency created for the public protection.”&lt;/p&gt;</description><link>http://jwage.com/post/30822442409</link><guid>http://jwage.com/post/30822442409</guid><pubDate>Mon, 03 Sep 2012 15:57:44 -0500</pubDate></item></channel></rss>
