45 articles Symfony, Twig, Doctrine & ORMs

Using raw PDO MySQL queries with safe placeholders in Symfony

This comes in handy as Doctrine doesn't always support all native MySQL commands and functions.  Strangely, certain common time and date-related ones like YEAR(), MONTH() and DAY(). The $paramsArr is an array for all placeholders in your standard PDO query.  

Symfony & Twig: Simple month and year form selection widget

This is a very useful Twig that I use in a lot of different forms.  I attach a listener and when they click "Update" it will redirect the user by appending the URL with the /year/month to hook nice and cleanly in built-in routes to pass the year and month into different controllers.  

Symfony & Doctrine: Using table joins with unassociated entities

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.  Here's an example query to illustrate, notice the "a.user = u.id". Some other helpful links on Stack Overflow:…

PHP Symfony Events: Developer tips to easily extend user administration and management within your code

A special thanks to James Halsall for some excellent tips in tapping into Symfony events through kernel listeners. His article explains how to create a service to trigger on certain events, this is related to the FOS User Bundle but the same pattern applies to most events in your Symfony project.  Click here to read…

In Symfony, moving some code from one bundle to another a simple way to modularize your code, reuse and scale. Oh yeah!

I recently ran into an issue where I found I was creating a new user profile system for different systems and then it occurred to my:  DRY.  DON'T REPEAT YOURSELF.  Yet, in the bustle of activity I realized there was too much in common with these user profiles to rewrite the code. So why not…