The diary and photos of Chris Beach. I'm into windsurfing, coding, badminton, drawing and composing music using computers and synths.

Let's start with a quote:
"I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours" Stephen Roberts


email: password:
Sign in with Google

fixing phlickr's internal php references so it can be used from scripts throughout a filesystem

Phlickr is the PHP5 API for the excellent photo-sharing website Flickr. It works well from what I've seen so far.

One problem though - the various PHP files within the Phlickr API reference each other using relative links i.e. require_once 'Phlickr/API.php', which means that all scripts that use the Phlickr API must be in the directory that contains the Phlickr directory. For me this proved inflexible as I nest my PHP scripts within various directories.

Therefore, I needed to run a substitution on the Phlickr API files in order to make the referenced paths absolute. Here we can use PHP's global $_SERVER['DOCUMENT_ROOT'] variable, which provides the physical filesystem path to the root directory serving up the PHP files. Here's a substitution command I came up with, which should be run within the Phlickr API directory:

find . -name "*.php" | xargs sed -i "s/'Phlickr\\//\$_SERVER['DOCUMENT_ROOT'] . '\\/Phlickr\\//g"

Note: this command works for me in bash - I haven't tried it in other shells.

After the substitution, the Phlickr API should be placed in this root directory, but other scripts that need to access it can be placed in subdirectories

written by Chris Beach
04/09/07 11:31pm
(6 years, 10 months ago)
comment add comment

photoadd photo

 3 links
more journal entries from tech journal