Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.


Stack Overflow

The old fashioned way


  Symfony Articles

August 20, 2009 – 12:24pm Getting a new developer started on an existing symfony project

Here is the basic process we use to get a new developer started on a symfony project. This flow assumes you already have created your symfony project and it checked into an svn repository somewhere, and that the developer is on a mac. More…

Posted by in  Web Development   |     |  Comments Off on Getting a new developer started on an existing symfony project

August 10, 2009 – 10:27am symfony configuration settings, “default” versus “all”

It’s hard to keep track of the difference between the “all” parameter heading and the “default” parameter heading in your security configuration files. The way to remember it is that “default” is just that — a value for when there are no other values set, including one for “all”. More…

Posted by in  Web Development   |     |  Comments Off on symfony configuration settings, “default” versus “all”

July 31, 2009 – 12:28pm Springloops deployment with svn externals

We’ve been trying out springloops as a hosted svn solution for one of our smaller projects, and so far it does the job just fine. We are using it to host the subversion repository for a symfony project. We generally like to use svn:externals for the symfony library files themselves, this way it its easy to upgrade symfony, make sure every deployment has the necessary code base without having to worry about having PEAR installed on every server. More…

Posted by in  Uncategorized   |     |  6 Comments »

July 13, 2009 – 10:37am Symfony: returning an array from app.yml

Sometimes its useful to return an array of values from app.yml. This is buried in the symfony docs so I thought I’d post it here just in case it’d help.

I’ve been using this technique to store a list of languages available on a site. As translations are ready for other languages, I add them to the list here and they automatically get pulled into the code in the appropriate places:

Posted by in  Uncategorized   |     |  7 Comments »

July 3, 2009 – 1:11pm Symfony: return javascript response

This is an old trick, but I still find it useful and will post it here in case it will help other symfony developers out there. If you are using the prototype.js library for your ajax requests, the Ajax.Request (and similar) utility methods will automatically evaluate the server’s response as javascript if the response has the ‘text/javascript’ content-type header. More…

Posted by in  Web Development   |     |  Comments Off on Symfony: return javascript response

April 10, 2009 – 12:56pm symfony cache system: cache growing too large

Symfony has a really powerful cache mechanism, but if you turn it on and don’t configure it, it will cache one file for *every possible url*, and in the case of a dynamic site with thousands of pages, this grows to many gigabytes very fast. This is especially a problem if you have a dynamic search feature, and you have search-friendly URLS where you convert query parameters to /a/friendly/path/like/this. The number of unique paths that generate content on your site is literally infinite, since the URL can include anything the user types in the search box. More…

Posted by in  Web Development   |     |  16 Comments »

March 14, 2009 – 2:46pm Symfony Propel Enum types

Propel does not support enum column types in its schemas, since the enum type is not support across all database types. There are a few ways around this. More…

Posted by in  Uncategorized   |     |  4 Comments »

March 11, 2009 – 1:55am Symfony: How to render a partial from an action

If you ever find yourself wanting to return the contents of a partial as the entire response for an action, Symfony makes it possible. Using symfony partials with ajax, you have a lot of options of how you want to arrange your templates, but here I’ll show you what has worked best for me.

Oftentimes I find myself wanting to return the contents of a partial as the entire response for an ajax request. I do this a lot when I am already using a partial in my template, and then I want to replace that section with the results of an ajax call. We already have a partial set up to display that content, so we might as well reuse it when we have to refresh that area with new content. More…

Posted by in  Uncategorized   |     |  7 Comments »

January 23, 2009 – 4:42pm Uploading a file with Symfony 1.2

There is a post hidden within the symfony documentation that discusses how to upload a file using the new forms framework within symfony 1.2. If you are curious about the best way to handle file uploads, it’s worth reading this What’s New in Symfony 1.2 post first, and then come back here for a quick summary of how this works.

Let’s say you would like to allow users to upload PDF files to your site. You store data related to these file uploads in an “article” table in your database. This table has a column named “file” that stores the file name of the uploaded pdf.

The symfony forms framework will generate the basic (and not so basic) code to get you started. If you haven’t yet generated your form classes yet, you can do so with the command:


December 23, 2008 – 9:09pm Symfony 1.2: upload a file inside an embedded form

Symfony 1.1 introduced the ability to embed forms inside other forms. Symfony 1.2 enhanced this feature greatly by providing the ability to automatically save any related objects found within these nested forms (see this blog post). Another new feature introduced in 1.2. is the ability to automatically handle file uploads in forms. Basically if you have a propel object with a file field, and define this field in your form validation schema as an sfValidatorFile, symfony takes care of removing any old field, saving the new one, and updating the column in the object to reflect the new file name. Pretty sweet. (You can read more about this feature in What’s New in 1.2.)

Everything is nearly perfect, except one problem: File fields in embedded forms are *not* processed automatically. It took me a long time to track down the issue, but it was a good opportunity for me to explore some of the new sfForm framework and really get under the hood to understand how it all works. More…

Posted by in  Uncategorized   |     |  28 Comments »