Archive > Category > Symfony
Symfony is a PHP framework that I use regularly in my work and personal projects. It’s a fantastic tool for developing large websites and you’ll find some useful snippets & walk-throughs filed here.
This is a super short snippet that I ALWAYS forget how to do! Often I want to build more complex where clauses with Propel Criteria which use SQL functions such as UCASE, LCASE, LEN and the date functions DAY, MONTH and YEAR. This is possible using Propel & Criteria, but how to do it is not immediately obvious.
The snippet below shows how to select objects from the database which were created in a specific month and year. Using Criteria::CUSTOM, it’s possible to specify a column and a comparison to do with that column. This is quite useful for doing things like building archive lists.
1 2 | $c->add(MyObjPeer::CREATED_AT, 'MONTH('.MyObjPeer::CREATED_AT.')='. $month, Criteria::CUSTOM); $c->addAnd(MyObjPeer::CREATED_AT, 'YEAR('.MyObjPeer::CREATED_AT.')='. $year, Criteria::CUSTOM); |
Perusing my Google Analytics data shows up some interesting results. For starters the top search query which sends people to my blog is “symfony accessing object in a form”. This has been consistent for several months, but there is no article on my blog which answers that question. I imagine this must be very frustrating for people so it’s about time I added the answer here as a snippet.
When working with large and complex datasets in Symfony, there comes a point where the ORM layer (Propel or Doctrine) causes more problems than it solves. Sometimes it’s necessary to debug large SQL queries built using the ORM layer, and at other times it’s appropriate to bypass the ORM layer entirely. The following snippets come from projects using Propel, I realise a lot of folks will have moved on to Doctrine but I hope there may be one or two useful things for that here too.
Generally, when I find something interesting I use twitter & delicious to spread the word, but this morning something in my RSS Reader got me excited enough to decide to write a blog post. Thomas Rabaix has hit the nail on the head with his latest offering: Wording is not a developer job. Not only with his underlying premise, but also with the solution he has developed and offered to the world.
Back in April I posted a Snippet on Symfony Form Formatters. Since then I’ve done a bit more work with them and thought I’d share my custom form formatter for displaying forms as definition lists. Forms are often marked up as unordered lists, but with their label-input structure I find they often make semantic sense as definition lists.
Symfony is one of my favourite bits of technology. I’ve got plans to write several articles and tutorials on it, but as I know many people haven’t yet heard of it, or are unaware of how it could help them, I thought it best to write an introductory article. So, here is an explanation of what Symfony is, why I use it, and why you may want to start using it too.



