Manually Installing PHPUnit with MAMP on Mac OS X 10.6 Snow Leopard


1. Get a copy of the latest version of PHPUnit (PHPUnit 3.4.6 – 4 Jan 2010) from http://pear.phpunit.de/get/

2. Extract your folder to your Desktop.

3. Edit “phpunit.php” found in “PHPUnit-3.4.6/PHPUnit-3.4.6/“.

3.1. Scroll near to the bottom and replace “@php_bin@” with “/Applications/MAMP/bin/php5/bin/php“.

3.2. Save as “phpunit” (no extension) in “/usr/local/bin/“, or save to your Desktop, then copy to “/usr/local/bin/“.

3.3. Make the phpunit file executable by typing the following in the Terminal:

sudo chmod +x /usr/local/bin/phpunit

4. Edit “PHP.php” found in “PHPUnit-3.4.6/PHPUnit-3.4.6/PHPUnit/Util/“.

4.1. Scroll about 3/4 near the bottom and replace “@php_bin@” with “/Applications/MAMP/bin/php5/bin/php“.

4.2. Save the file and copy the “PHPUnit-3.4.1/PHPUnit-3.4.1/PHPUnit” folder to “/usr/lib/php/“.

5. Test it out by making a test anywhere, here is some sample code you can plonk into “SampleTest.php“.

<?php
class SampleTest extends PHPUnit_Framework_TestCase
{
    public function testHowsit() {
        $this->assertTrue(1 == 1);
    }
}
?>

6. Open up your Terminal to where your test (SampleTest.php) is located.

7. Run the test using:

/usr/local/bin/phpunit SampleTest.php

You should see the following:

PHPUnit 3.4.6 by Sebastian Bergmann.

.

Time: 0 seconds, Memory: 5.75Mb

OK (1 test, 1 assertion)

[Credit goes to TigerMunky at http://tmshweetness.blogspot.com/2009/10/manually-installing-phpunit-with-mamp.html]

Adding Expires headers with Apache Module mod_expires

As part of my efforts to improve the performance www.epiphanyrisknetwork.com, I wanted to set Expires headers on components so that they become cacheable and avoid unnecessary HTTP requests on subsequent page views. (Ref: http://developer.yahoo.com/performance/rules.html#expires)

I’ll be improving this over time, but so far I have the following in my .htaccess file:

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType image/gif "access plus 1 months"
  ExpiresByType image/png "access plus 1 months"
  ExpiresByType image/jpeg "access plus 1 months"
  ExpiresByType image/ico "access plus 1 months"
  ExpiresDefault "access plus 1 days"
</IfModule>

Let’s break this down…

  ExpiresActive on

The first directive simply informs that the module should be used.

  ExpiresByType image/gif "access plus 1 months"
  ExpiresByType image/png "access plus 1 months"
  ExpiresByType image/jpeg "access plus 1 months"
  ExpiresByType image/ico "access plus 1 months"

The second through to fifth directives deals with specific image types. So the first of these informs that GIFs should be reloaded from the web server one month after the document was last accessed.

  ExpiresDefault "access plus 1 days"

The sixth and final directive informs that all document types that are not specified should be reloaded one day from the current time.

The time parameters in the quotes may be access (A) or modification (M). Setting now is also valid, this is the same as access. Setting A or access produces the same result. It is preferrable to use access over modification because modification only can be applied to files that come from disk, apache does not figure out modification time for other objects and omits the header in these cases.

The plus key is not needed and is only optional to make the configuration files easier to read.

The time length is specified in seconds by default, or any of the following keys can be used:

  • years
  • months
  • weeks
  • days
  • hours
  • minutes
  • seconds

So:

  ExpiresDefault "access plus 2 minutes"

is equal to setting the slightly more cryptic:

  ExpiresDefault "A120"

Post Office and Roxburghe Incompetence

I hope no one else falls foul of the incompetence of the Post Office and Roxburghe debt collection.

After cancelling, within my rights, a new telephone line installation with the Post Office, they have demonstrated a total inability to properly close the account.  Despite numerous phone calls over half a year, and reassurances from their staff that the account is closed and no debt is owed, and I still receive automated overdue bill notifications.  When asked for written confirmation of the account closure staff are “unable” to fulfil such a basic request.  Come on Post Office, this is pathetic – get your basic business processes functioning!

The situation was then compounded by starting to receive letters from a debt collection company called Roxburghe.  Roxburghe are unhelpful, unprofessional and insulting in their correspondence .  (Misspelling their own company name on correspondence certainly doesn’t boost credibility.)  The statement on their FAQ page that, “Roxburghe will always treat you in a courteous and professional manner,” is meaningless.  Companies which operate in the manner in which they do should not be in business.  An organisation such as the Post Office will only damage their reputation by employing the services of such an organisation.  However the Post Office only has itself to blame for incorrectly passing customer details like mine on to such agencies.

That is all I have to say on the matter.

How To Install PEAR in Mac OS X Leopard

Unlike previous version of OS X, Leopard doesn’t come with PHP’s PEAR repository installed by default. Luckily, installing is quick and painless.

From a command line:

curl http://pear.php.net/go-pear > go-pear.php
sudo php -q go-pear.php

(Just press enter to select all the default choices.)

Next we need to modify our php.ini file to include the new PEAR files:

sudo cp /etc/php.ini.default /etc/php.ini

Edit /etc/php.ini and change

;include_path = “.:/php/includes”

to read

include_path = “.:/usr/share/pear”

Restart Apache and you’re done!

[Adapted from http://clickontyler.com/blog/2008/01/how-to-install-pear-in-mac-os-x-leopard/]

Setting up Tomcat as a service on Linux

If you want Tomcat to start automatically on boot then you need to set it up as a service. To do this you need to copy the code below and save it as a file called tomcat in the folder /etc/init.d:

# This is the init script for starting up the
# Jakarta Tomcat server
#
# chkconfig: 345 91 10
# description: Starts and stops the Tomcat daemon.
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

tomcat=/usr/share/tomcat
startup=$tomcat/bin/startup.sh
shutdown=$tomcat/bin/shutdown.sh
export JAVA_HOME=/usr/java/jre1.5.0_12/
export CATALINA_HOME=/usr/share/tomcat

start(){
echo -n $”Starting Tomcat service: “
$startup
RETVAL=$?
echo
}

stop(){
action $”Stopping Tomcat service: ” $shutdown
RETVAL=$?
echo
}

status(){
numproc=`ps -ef | grep catalina | grep -v “grep catalina” | wc -l`
if [ $numproc -gt 0 ]; then
echo “Tomcat is running…”
else
echo “Tomcat is stopped…”
fi
}

restart(){
stop
sleep 5
start
}

# See how we were called.
case “$1″ in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|status|restart}”
exit 1
esac

exit 0

You may have to change the value for tomcat and JAVA_HOME if Tomcat and your JDK are in different locations to mine. You then need to make the file executable with the command:

sudo chmod +x /etc/init.d/tomcat

And finally you need to set it to start at boot with the command:

sudo chkconfig –add tomcat

You now have a working Tomcat install that will start it self at boot time. You can also interact with it using the service command to start, stop, restart and see the status of the service at any time. E.g.

sudo service tomcat start
sudo service tomcat satus
sudo service tomcat stop

[Adapted from http://www.bartbusschots.ie/blog/?p=240]

Solihull to Manchester Airport

Dad was flying off from Manchester Airport last weekend so put “solihull to manchester airport” in to the UK version of Google Maps.

My favourite is step 27, “Swim across the Atlantic Ocean”. That’s 3,462 miles in (apparently) 29 days. Um, yeah.

Installing Java on Ubuntu Feisty Fawn 7.04

Just tell aptitude to install Java 1.5:

sudo aptitude install sun-java5-jdk

You can check Java is installed correctly by typing:

java -version

[Taken from http://ubuntuguide.org/wiki/Ubuntu:Feisty]

Apache Tomcat 5.5 on Ubuntu Edgy Eft 6.10

Step 1 – Install JRE and SDK

Check the version of Java by typing:

java -version

Use these instructions to install if necessary.

Step 2 – Get Tomcat

Download Tomcat 5.5 from http://tomcat.apache.org/. In this example I am using apache-tomcat-5.5.23.tar.gz

Move to file to /usr/share and decompress:

tar zxf apache-tomcat-5.5.23.tar.gz

Step 3 – Add a Symbolic Link

To make things simpler I added the symbolic link ‘tomcat’ which points to the apache-tomcat-5.5.23 directory. Within /usr/share type:

ln -s ./apache-tomcat-5.5.23 ./tomcat

Step 4 – Set JAVA_HOME and CLASSPATH

You need to point out where you installed Java SDK. You will have to edit the file ‘.bashrc’. (I suggest you backup first just in case.) In terminal type:

sudo nano ~/.bashrc

Add the following lines to the file:

# for tomcat
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.06/
export CLASSPATH=”/usr/share/tomcat/common/lib/jsp-api.jar;/usr/share/tomcat/common/lib/servlet-api.jar”

Save and close. You will have to log out and back in again before these changes take effect.

Step 5 – Starting and stopping tomcat

Tomcat should now be ready to run. In terminal type:

sudo /usr/share/tomcat/bin/startup.sh

If everything is working fine, you will see the following lines:

Using CATALINA_BASE: /usr/share/tomcat
Using CATALINA_HOME: /usr/share/tomcat
Using CATALINA_TMPDIR: /usr/share/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-1.5.0-sun-1.5.0.06/

In your browser head to http://localhost:8080/ and test.

To stop Tomcat type:

sudo /usr/share/tomcat/bin/shutdown.sh

[Adapted from http://doc.gwos.org/index.php/Install_tomcat_5.5]

[27-07-2007: Also see http://www.bartbusschots.ie/blog/?p=240]

Installing Java on Ubuntu Edgy Eft 6.10

You need to ensure that apt-get is pointed at the right place. In /etc/apt/sources.list add in the following:

deb http://us.archive.ubuntu.com/ubuntu dapper main restricted
deb http://us.archive.ubuntu.com/ubuntu dapper universe multiverse

After this have apt updates its repository:

sudo apt-get update

And finally, just tell it to install Java 1.5:

sudo apt-get install sun-java5-jdk

You can check Java is installed correctly by typing:

java -version

[Adapted from http://www.javalobby.org/java/forums/t72809.html]

Posted in Tech, Work. 1 Comment »

OpenSEF in Joomla

There are two things I like to apply to an installation of Joomla to improve its Search Engine Friendly (SEF) functionality.

OpenSEF

OpenSEF is a Joomla 1.0.x component that extendes Joomla’s SEF URL mechanism allowing you to define arbitary, friendly URLs for any of Joomla’s content and component items. (Installation instructions.)

Joomla SEF Patch

The out of the box installation of Joomla is not fully optimized for search engine optimising features – the Joomla SEF patch aims to improve this. You can read more about the free verson of the SEF patch.

Joomla SEF Patch is listed on the Joomla! Extensions site. It can be downloaded from http://www.joomlatwork.com/downloads/.

(Using Transmit‘s Merge Folder function makes this a breeze.)

Follow

Get every new post delivered to your Inbox.