Tag: PHP
2011
09.18

I’ve used new relic with my rails apps for over a year now and like the service a lot. I recently noticed that they have integration with php so I decided to get the php agent configured on my server so I could get stats on an upcoming symfony 2 app.

I use Nginx / PHP-fpm to run my php apps on ubuntu. The install instructions on the new relic site worked pretty well except for one minor quirk.

I had to install php5-dev so that the new relic install script had php-config to execute to find out information about my install. After that, the install script kept complaining that it could not find a valid php install on the system.

With this particular setup, new relic would look for php in /usr/bin/php (from the php-config script) but that did not exist. There was /usr/bin/php5-fpm and /usr/bin/php5-cgi.

I created a symlink for /usr/bin/php and reran the install script.

Success!

2009
09.24

On a recent Symfony 1.0 project I’ve been working on, I noticed that there were quite a few pages that heavily made use of a particular database table that basically held a set of data that would rarely change. I thought it would be nice to implement a second level cache for  these objects at the ORM level,  I used to use a similar technique with Hibernate and EHCache on my Java projects.

I started poking around the Propel documentation, looking into what features they had to offer in this area and came across a few forum posts requesting that sort of second level cache functionality, but it looked like those features were not going to be implemented until a later release, not going to do me much good for my current project.  But I found a way, and it turned out to be pretty simple.  enter memcache function caching.

Read More >>

2009
09.09

A good ORM is hard to find

Every so often in our development lives, we’ll all ask ourselves why we are using an ORM instead of writing SQL by hand.  Most often when people think about using an ORM, it is thought about in terms of keeping a layer of abstraction between the application and the specifics of the database used to store data.  What I think often gets overlooked is that an ORM provides a layer for a framework to wrap boiler plate functionality, to varying degrees, like automatic / declarative transaction handling,  automatic query logging and protection against SQL injection attacks.

Transactions at a glance

Transactions let us define little units of SQL functionality that must occur all together or not at all.  Let’s use the age old example of a travel website as an example.  Let’s say a user wants to book a package that includes an airline reservation, hotel reservation and a rental car reservation.  The customer wants to book all of these reservations together, or does not want to take the trip at all.  So let’s look at a few scenarios which illustrate how this could be handled:

Read More >>