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

If you have any opinions about these quotes then vote on the quotes page. Here's another:
"Religion is regarded by the common people as true, by the wise as false, and by the rulers as useful." Seneca the Younger 4 b.c.- 65 a.d.


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 10:31pm
(7 years, 2 months ago)
comment add comment

photoadd photo

 3 links
more journal entries from tech journal


Pulled from cache