SUBSCRIBE VIA RSS


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.

Topics

Stack Overflow


The old fashioned way

RECENT TUNES

  Archive for July, 2009

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

How have I never seen this before today?

PHPExcel

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 28, 2009 – 12:55pm On the cost of websites

This is an excellent post on the cost of building websites, what drives these costs, acquiring traffic, and more.

How much do websites cost?

Posted by in  Web Development   |  Comments Off on On the cost of websites

July 27, 2009 – 11:07am IE 6 getElementsById() and prototype $() function return dom elements by *name*

I can’t believe I had not run into this yet, but today I had a page that had an element (an anchor) with a name attribute (“floorplans”), and further down the page a div with that id (“floorplans”). When I tried to dynamically load content into my div using $(‘floorplans’), things were getting all out of control on IE 6. Turns out IE6’s document.getElementById returns the first element whose id OR name matches the string, and of course Prototype’s $() function relies on the browser’s own getElementById(). Lesson learned!

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.
More…

Posted by in  Web Development   |     |  3 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:
More…

Posted by in  Uncategorized   |     |  7 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)
NULL
FALSE
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 »

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

July 1, 2009 – 6:30pm Firebug and Firefox 3.5

I rely on Firebug daily to help me debug javascript and work with css. After upgrading to Firefox 3.5, I updated Firebug to the latest beta release, Firebug 1.4 Beta.

The beta version is of course rough around the edges, and one rough spot is the fact that often when editing css properties of an element on an html page, the entire style definition would simply disappear from the console.

Fortunately, as of today, the firebug-1.5X.0a07.xpi release fixes the problem. Click the link for 1.5X0a07.xpi within Firefox to update. I haven’t found any serious problems with the alpha version yet.

As a side note, if any of you are Safari users or are just testing your sites out for safari, make sure you enable the development menu (Preferences > Advanced > Enable Develop Menu) and then you can use the command-option-i to show a Firebug-like inspector. It’s growing on me each time I use it.

Posted by in  Uncategorized   |     |  2 Comments »