Articles

Symfony, Twig & Doctrine ORMs

The framework this site has the most to say about: Twig templates, Doctrine mappings and queries, forms, and the security bits that changed under everyone.

Everything in Symfony, Twig & Doctrine ORMs

  • Doctrine Arbitrary Table Joins on Unassociated Entities

    01/25/2016

    Doctrine: joining entities with no association

    In Symfony using Doctrine, if no association is available for two entities, you can still join them and treat them like they have a relationship. To do so, you have to use the “Join: WITH” method.

  • Extending a parent Twig block with parent()

    11/30/2015

    Extending a parent Twig block with parent()

    Define a block in a child template and it replaces the parent's version completely - which is rarely what you wanted for a block holding stylesheets or scripts. parent() puts the inherited content back.

  • Conditional User State in Twig Views

    04/28/2015

    Show the logged-in user in a Twig template

    The snippet everyone has saved uses app.user.username, which throws on every supported Symfony. Here is the version that works, which check to guard it with, and how to greet somebody by name rather than by email address.

  • Dynamic field names in Twig with attribute() and ~

    04/14/2015

    Dynamic field names in Twig with attribute() and ~

    Dot notation cannot reach a property whose name you are building in the template. attribute() takes the name as a string, the tilde concatenates it, and `is defined` keeps the loop from throwing on a gap.

  • Doctrine ORM MySQL Field Type Definitions

    03/24/2015

    Doctrine field type mappings: tinyint is a boolean

    A MySQL tinyint is mapped to boolean regardless of its declared length, so a column holding 0 to 100 comes back as true. The full type table, and the two ways to get an integer back.