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


  PHP Articles

January 13, 2011 – 6:43pm Using CURL through a SOCKS proxy to post XML data

Recently we had to communicate with an API that requires we post XML from a white-listed IP address. This made it difficult to develop against since the only way we could get a response from the API service was if we were accessing it from our production machine. This is how you set up PHP’s cURL (client URL) library to post xml data through a proxy server.

Posted by in  Web Development   |     |  1 Comment »

February 12, 2010 – 6:11pm WordPress get post images and the_post_thumbnail caption

Before the_post_thumbnail was available, here is how I would fetch an array of images that were attached to a post in wordpress:

Posted by in  Web Development   |     |  5 Comments »

August 17, 2009 – 12:03am http_build_query

I can never remember the name of this function. I always google and search the php docs for things like ‘php query params’, ‘php url parameters’, ‘php query string from array’, ‘php http query params’, and I even saw “php array to post string” and for some reason this page just never comes up. Yes, this post is a selfish way for me to find this next year when I search my blog for this post!

Posted by in  Web Development   |     |  Comments Off on http_build_query

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 29, 2009 – 5:51pm PHP import excel (xls) files to array or csv

How have I never seen this before today?


I’ve only been working with it for a few hours but it’s amazing. It can read and write from many different formats.

Output your spreadsheet object to different file formats

  • Excel 2007 (spreadsheetML)
  • BIFF8 (Excel 97 and higher)
  • PHPExcel Serialized Spreadsheet
  • CSV (Comma Separated Values)
  • HTML
  • PDF

Read different file formats into your spreadsheet object

  • Excel 2007 (spreadsheetML)
  • BIFF5 (Excel 5.0 / Excel 95), BIFF8 (Excel 97 and higher)
  • PHPExcel Serialized Spreadsheet
  • CSV (Comma Separated Values)

I am very excited about this. Another honorable mention is php-excel-reader which might be worth a look if you just want something a bit more simple.

Posted by in  Web Development   |     |  2 Comments »

July 21, 2009 – 5:06pm Propel criteria on custom columns (with addAsColumn)

This still trips me up. If you are using propel criteria objects and want to add a condition on a custom column, you have to do a bit of trickery to get it working just right. More…

Posted by in  Uncategorized   |     |  4 Comments »

July 16, 2009 – 1:38pm PHP Doctrine: Fetching related objects with hasOne relationship or one-to-zero-or-one

People new to the Doctrine ORM have a hard time understanding the magic that happens behind the scenes when you want to fetch a related object through a has-one-or-zero relationship. Looking through the doctrine-user group, it’s clear there is a lot confusion on this to newcomers, especially if you are coming over from Propel or other ORMs. It can be a pretty big conceptual change to how things are done.

Posted by in  Web Development   |     |  3 Comments »

July 11, 2009 – 2:52am php isset and not empty

I find myself doing this a lot:

if (isset($myarray['foo']) && $myarray['foo'])) {
  // do something

But I thought there had to be a better way, and one that would not throw undefined errors. A quick google search came up with a few good hits, include the PHP manual page for empty().

The manual says that when using empty(), no warnings are thrown when a variable is not set. It will return true in the following cases:

“” (an empty string)
0 (0 as an integer)
“0” (0 as a string)
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

Keep in mind that an object with no properties is not considered empty().

Now, we can make our code a bit more beautiful:

if (!empty($myarray['foo'])) {
  // do something

I’ve known about empty() for a long time, but for some reason always seemed to choose isset() over empty(), even in cases like this.

Posted by in  Uncategorized   |     |  3 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 »