Month: September 2006

  • Remote PHP debugging

    After 8 or so years of being a professional web developer I today finally cracked using a debugger with PHP. I’ve been a long suffering PHPEdit user from since it was open source and into having to pay (twice) for a licence. Unfortunately I started getting very irritated by some annoying and performance degrading bugs…

  • My PHP application directory structure

    Rob Allen, who is on PHPWM and who I met at the recent PHPWM meeting in Worcester posted something on his blog detailing his prefered directory structure recently. Here's mine, seemingly nicked straight from FHS: /home/$USER/www/$PROJECT: /codebase /bin // anything with a shebang in /etc // config files /htdocs // document root /lib /class /function…

  • Nightmare MySQL migration

    I've been migrating a large number of websites over from one server to another, always an enjoyable task. So I get to the last one, copy the database over and do the normal mysql import along the lines of: [code]mysql -ufoo -pbar database_name < database_name.sql[/code] Errors++ Turns out the Donke^H^H^H^HDeveloper who built the application didn't…

  • Excluding folders when creating a tarball

    When creating a tarball, to exclude folders one simply uses the –exclude= flag: For example to tar up the contents of /var/log but to exclude /var/log/apache & /var/log/mail/ tar -jcvf logfiles.tar.bz2 /var/log/* –exclude=/var/log/apache/* –exclude=/var/log/mail/* Just in case you didn't already know then the 'j' flag in the 'jcvf' tells tar to use bzip2 compression.

  • Perl MySQL backup script.

    I’m in the middle of migrating a lot of websites from one server to another. Here’s a small script I knocked up to take a dump of all the MySQL databases on that machine: [perl]#!/usr/bin/perl -w use strict; my $dumpDir = “/tmp/foo”; my $dumpUser= “root”; my $mysqlBin = “/usr/local/mysql/bin”; my $mysqlPassword = “bar”; foreach (`ls…

  • Emulating PHP’s substr() with Smarty [sort of]

    Today I had a requirement to strip off the first 9 digits from a string from within a Smarty template. The system using Smarty is *totally* locked down so no access to plugins or using php functions as modifiers so I could not simply do $string=substr($string,9); or even {assign var=”shorterThing” value=$thing|substr:9} In the end I…