Installation of PHPUnit on a Dreamhost Account

I know it’s been awhile since I posted here.  I needed to get some other web work complete, such as the Trenton 1784 website, which took me away from the Zend Framework for a bit.  Now I am back at it.

Since I have the Zend Framework in Action book, in order to fill out my knowledge of Zend, I wanted to get my server fully set up for the applications in this book and this required the downloading of PHPUnit in order to do the Unit Testing.  Now it doesn’t seem like this would be a requirement to actually go through the book,  but I had always done unit testing when I was a consultant developing desktop apps for Fortune 500 companies.  Since Zend Framework in Action also explains how to use PHPUnit, I might as well take advantage of it.

First a note about installing this. These are merely steps that I took to get PHPUnit to wok for me.  I can not be held responsible for anything that may happen during these steps.  I have tried to lay them out as clearly as I could and in an easy to follow process.  It did take me some trial and error, as well as researching several websites to put this all together.

Installing it is like piecing together a puzzle – trying to find the next bit of information that someone may have left out.  Just downloading it was a bit of challenge since I wasn’t going to be using the Pear Installer.  First I had to look for where to download the zip file from. On the main page they have a Install PHPUnit link.  Okay, so I thought that would bring me to the download page. Nope – it brings me to the instructions on how to install it in the PDF manual.  At first I thought this wasn’t what I wanted, which was my own damn fault for just glancing at it, so I went back to the main screen to see if they had a “Download Link”, which they didn’t.  After looking at various links, I went back to the install link and read that page.  Although it was not hotlinked – the link for downloading PHPUnit manually was in there – http://pear.phpunit.de/get/

So I downloaded the PHPUnit-3.4.3.tgz file and FTPed to the server (you can’t use Dreamhost’s WebFTP since it is over 2 meg -  I used Dreamweaver and of course you can use any FTP program you wish).  Now that it was on the server, I had to see how to set it up on a Dreamhost account that is on a  shared server. These are the steps I had to take.  I am putting these here because I noticed while doing searching that others were trying to figure out the same thing (some things I have already had set-up, such as putty, but I will go through them so anyone completely unfamiliar will be able to follow from start to finish.

Using Putty to get into Dreamhost account

1) First get Putty – no installation required, just download and run.

2) Enter in the hostname – this is just your website  without the “http://www” – i.e.,  “somedomain.com”

3) Click Open at the bottom.

4) When the black command line screen comes up it will first says “login as”. Just type in the dreamhost user name which you use to FTP into dreamhost.

5) It will then ask for the specific account’s password.  Type in the password that you use to FTP into that account with.

6) If everything goes okay – you should see the console welcome screen.

If you do a dir command, you will see that you are on the root level of your account’s directory. You can easily get back to this directory by just typing “cd $HOME

Installing PHPUnit

1) Make sure the PHPUnit-x.x.x.tgz file is in your root account directory.  If it isn’t – then go to the directory you saved it in and copy it in the home directory by typing cp PHPUnit-x.x.x.tgz $HOME

2) Unzip the tgz file by issuing this command – tar -zxvf PHPUnit-x.x.x.tgz I found this on the DreamhostWiki

3) Now create the local/bin directory if it is not already created by issuing this command mkdir -p $HOME/local/bin

4) Back to the PHPUnit installation instructions – you need to rename the phunit.php file  to just phpunit (note the lowercase) without the .php extension and copy it to your local/bin directory by issuing this command cp PHPUnit-x.x.x/phpunit.php $HOME/local/bin/phpunit. You can find this file located in the PHPUnit-x.x.x subdirectory which was created when the tar file was unzipped. NOTE: the Dreamhost PHPUnit Installation instructions says that the file is located in the PHPUnit-x.x.x/bin directory – which there no such directory, at least in version 3.4.3 which is the latest. Also, it says nothing about having to rename the file.

5) Now set up the paths.  I first tested these out one at a time without changing the .bash_profile to make sure it worked.

6) You have to set a path to the PHP5 Command Line interpreter.  The instructions for Dreamhost I found here – PHP-CLI (Using PHP from the Command line) You want to enter – export PATH=/usr/local/php5/bin/:$PATH
Type php – v to make sure it work. It should give you the PHP CLI version information.

7) Set the path for your local/bin directory  so it will find the phpunit file. Enter in – export PATH=$HOME/<accountname>/local/bin:$PATH
Type phpunit –help (Note: This will still give you an error because it is not able to find the other files in the PHPUnit-x.x.x/PHPUnit directory – we will add that path next.  It should find at least the PHPUnit file though, attempt to run it and not give an command not found message.)

8 ) Set up the path to find the rest of the files required by PHUnit.  I kept these in the original subdirectory which is located in PHPUnit-x.x.x/PHPUnit.  Just enter export PATH=$HOME/<accountname>/PHPUnit-x.x.x:$PATH

9) Now test it the whole thing out by entering phpunit –help If everything worked you should get the version information and help screen.  If you didn’t make sure that all your path’s are entered in correctly with the proper upper and lower cases.

Making the Changes Permanent in the .bash_profile

Once you have gotten that to work you want to make those paths permanent so you don’t have to retype them every time you log in. This requires putting them into your .bash_profile (note the period before the file name – just like .htaccess)

1) Enter cd $HOME to make sure you are in the root directory

2) Enter vi .bash_profile (This will bring you to the vi editor)

3) The vi editor opens in view mode and you need to change to edit mode – so hit the a key You should now be able to edit the file.

4) Cursor  down to the end of the last line and hit enter (you should now have a new line to enter in information). Enter this -

PATH=$HOME/<accountname>/PHPUnit-x.x.x:$HOME/<accountname>/local/bin:/usr/local/php5/bin/:$PATH

That line is made up of the three paths we entered before – just concatenated together and are now in the .bash_profile file.

5) Now to save the file.  Hit the esc key to get out of edit mode. Type : x  (no space between the colon and the x) to save and exit.

To test to make sure the .bash_profile works you need to  logout of the command line by typing logout and enter.  Log back in using Putty (which is described above) After logging in, if you type in phpunit –help now, it should give you version and help information as it did before but without you having to manually type in the paths.

If it doesn’t work, double check your paths and make sure everything is correct. It seemed as if the path to PHPUnit-x.x.x had to appear first for some reason.  When I didn’t have it first it generated a  PHP error.  It could be possible that Dreamhost has a copy of PHPUnit somewhere on their system that it could be picking up if it doesn’t search in YOUR PHPUnit directory first.

2 Responses to “Installation of PHPUnit on a Dreamhost Account”

  1. Thank you for the very helpful instructions.

    In my case, copying the phpunit.php file to the local/bin directory did not work. PHPUnit failed to find the required included files. However, renaming the phpunit.php file and executing it within its current directory did work. I am on a Dreamhost Private Server, though I don’t know if that makes a difference.

  2. Scott – thank you. When I tried doing this, I had t piece the instruction together from several sites.

    I’m not sure about if you have a dedicated server, if it would be any different, i wouldn’t think so. I was wondering, did you include the local/bin directory in your path (steps 7 & 8)? That would be the only thing I would think of that might cause it not to work. But the main thing is that you were able to get it to work with what you did.

Leave a Reply

  • Buy Cheap clomid information Now Buy Medications Online. Online Medical Shop.
  • Buy Cheapest antianxiety drugs Now Best Drugstore. Cheap Prescription Drugs.
  • Buy Cheapest medications for weight loss Now Best Prices. Cheap Prescription Drugs.
  • Buy Cheap buy tadalafil brand online Now Best Prices. No Prescription Online Pharmacy.
  • Buy Cheap tramadol online Online Pharmacy Store. Drugs, Health And Beauty.
  • Buy Cheap blue pills 180 Now Online Prices For blue pills 180! Top Online Pharmacy.
  • Buy Cheapest cheap cialis generic mastercard Now Cheap Pharmacy Online. Top Online Pharmacy.
  • Buy Cheap headache relief medications Online Top Online Pharmacy Supplier. Best Prices.
  • Buy Cheap dose ultram Now Best Internet. Special Prices For dose ultram!
  • Buy Cheap ordering ambien Now Free Viagra Pills! Pharmacy At The Best Price!
  • Buy Cheap diet pill Online Best Prices. Online Prices For diet pill!
  • Buy Cheap no prescription medication Now Bonus Pills And Reorder Discounts! Low Prices.
  • Buy Cheap codeine products europe Now Best Drugstore. No Prescription Needed.
  • Buy Cheapest valium used Now Discount Pharmacy Online. Low Prices.
  • Buy Cheapest cialis softabs Now WorldWide Shipping. Top Online Pharmacy.
  • Buy Cheap what is bactrim Now No Prescription Online Pharmacy. Best Prices.
  • Buy Cheap medical discount international drug Online Online Prices For medical discount international drug! Pharmacy Store.
  • Buy Cheapest strongest appetite suppressant Online Online Medical Shop. Best Internet.
  • Buy Cheap top pain pills online Online Best Drugstore. Buy Medications Online.
  • Buy Cheapest parasite medications Online Guaranteed Shipping. Free Viagra Pills!
  • Buy Cheap purchase ambien Now Low Prices. Top Online Pharmacy Supplier.
  • Buy Cheap buy cheap tadalafil uk Now No Prescription Needed. Cheap Pharmacy Online.
  • Buy Cheapest zoloft lexapro Now Special Prices For zoloft lexapro! Best Internet.
  • Buy Cheap purchase online prescription depression medications Now Drugs, Health And Beauty. Best Drugstore.
  • Buy Cheapest ativan generic name Online Online Medical Shop. Best Online.
  • Buy Cheap norvasc dose Now Drugs, Health And Beauty. WorldWide Shipping.
  • Buy Cheapest buyimg viagra in australia Now Pharmacy Store. Cheap Online Pharmacy.
  • Buy Cheapest breast cancer support Online Free Viagra Pills! Guaranteed Shipping.
  • Buy Cheapest drugstore diet pills Online Best Drugstore. Free Viagra Pills!
  • Buy Cheapest free viagra sample viagra sample Online Cheap Online Pharmacy. Low Prices.
  • Buy Cheap viagra generic brand Online Best Prices. Special Prices For viagra generic brand!
  • Buy Cheap accutane buy canada pharmacy Now WorldWide Shipping. Online Prices For accutane buy canada pharmacy!
  • Buy Cheap canadian pharmacy ltd Now Cheap Pharmacy Online. No Prescription Needed.
  • Buy Cheap purchase clomid Now Low Prices. Internet Prices For purchase clomid!
  • Buy Cheap multi vitamin supplement Now Online Medical Shop. 24/Online Pharmacy.
  • Buy Cheap what is viagra professional Now Low Prices. Cheap Meds Without Prescription.
  • Buy Cheapest online tylenol with codeine no prescription Online Discount Online Pharmacy. Best Internet.
  • Buy Cheapest phentermine no prescriptions Now Free Viagra Pills! Cheap Pharmacy Online.
  • Buy Cheap cheap discount viagra Now Top Online Pharmacy. Cheap Online Pharmacy.
  • Buy Cheap arthritis buy online Online WorldWide Shipping. 24/Online Pharmacy.
  • Buy Cheapest lexapro benefits Now Free Viagra Pills! No Prescription Needed.
  • Buy Cheap buying xanax Online Order Cheap Meds Without Rx. Best Online.
  • Buy Cheap depression drugs Now Top Online Pharmacy. Cheap Pharmacy Online.
  • Buy Cheapest tramadol info Online Pharmacy Store. Guaranteed Shipping.
  • Buy Cheap xanax medication Now Top Online Pharmacy. Guaranteed Shipping.
  • Buy Cheap how to take valium Now Pharmacy Store. Pharmacy At The Best Price!
  • Buy Cheapest buy generic ultram Online Pharmacy Store. Guaranteed Shipping.
  • tramadol no prescription Online Without Prescription Low Prices. WorldWide Shipping.
  • Buy Cheap human parasite treatment Now Best Drugstore. Internet Prices For human parasite treatment!
  • Buy Cheapest rimonabant buy online Online Free Viagra Pills! WorldWide Shipping.
  • Buy Cheap generic sildenafil Online 24/Online Pharmacy. Online Medical Shop.
  • Buy Cheap online cheap viagra buy Now Online Medical Shop. Discount Online Pharmacy.
  • Buy Cheap online drugs Now Top Online Pharmacy. No Prescription Needed.
  • Buy Cheapest cheap discount tramadol Now 24/Online Pharmacy. Pharmacy Store.
  • Buy Cheap weight loss programs online Now Free Viagra Pills! Cheap Pharmacy Online.
  • Buy Cheapest online pharmacies in mexico Now Cheap Online Pharmacy. Guaranteed Shipping.
  • Buy Cheapest viagra experiences Online WorldWide Shipping. Free Viagra Pills!
  • Buy Cheap cialis generic pharmacy online Now Online Medical Shop. Free Viagra Pills!
  • Buy Cheap get off klonopin Online Free Viagra Pills! 24/Online Pharmacy.
  • Buying Cheapest medicine levitra. Mexican Pharmacy, Best Prices. Best Prices.
  • Buy Cheapest legal codeine in canada Now Pharmacy Store. Discount Pharmacy Online.
  • Buy Cheap most effective weight loss supplement Online Online Prices For most effective weight loss supplement! Best Online.
  • Buy Cheap prices tramadol Online Best Drugstore. Discount Online Pharmacy.
  • Buy Cheap daily dose cialis availability Online 100% Satisfaction Guaranteed. Best Online.
  • Buy Cheapest cialis side effect Online Low Prices. Order Cheap Meds Without Rx.
  • indian viagra Online Without Prescription WorldWide Shipping. Best Prices.
  • Buy Cheapest ultram buy ultram Now Best Drugstore. 24/Online Pharmacy.
  • Buy Cheap discount drugstore Now Best Prices. 100% Satisfaction Guaranteed.
  • Buy Cheap female version of viagra Online Discount Online Pharmacy. Best Internet.
  • Buy Cheapest buy cialis generic Now The Largest Internet Pharmacy. Low Prices.
  • Buy Cheapest valium no rx Now Pharmacy At The Best Price! Best Internet.
  • Buy Cheap brand levitra Online Cheap Online Pharmacy. Best Drugstore.
  • Buy Cheap dietary supplement Now Top Online Pharmacy. Online Prices For dietary supplement!
  • Buy Cheap valium indications Now No Prescription Needed. 24/Online Pharmacy.
  • Buy Cheap non prescription drugs Now Online Medical Shop. Online Prices For non prescription drugs!
  • Buy Cheap diet and weight loss Now Guaranteed Shipping. Cheap Pharmacy Online.
  • Buy Cheap buy drugs prescription online Now No Prescription Needed. WorldWide Shipping.
  • Buy Cheapest supplement for appetite control Now 24/Online Pharmacy. Pharmacy Store.
  • Buy Cheapest effects of norvasc Online Buy Medications Online. Best Prices.
  • Buy Cheapest cialis gel Now Cheap Online Pharmacy. Online Medical Shop.
  • Buy Cheapest herbal appetite suppressant Now Discount Pharmacy Online. Pharmacy Store.
  • Buy Cheap femara infertility Now 24/Online Pharmacy. Free Viagra Pills!
  • Buy Cheap buy canadian drugs Online Online Medical Shop. Best Drugstore.
  • Buy Cheapest medicine for stress Now Online Medical Shop. Top Online Pharmacy.
  • Buy Cheapest internet prescription drugs Online Cheap Online Pharmacy. Best Prices.
  • Buy Cheap cialis effect on women Online Best Drugstore. Cheap Online Pharmacy.
  • medicine cialis Online Without Prescription Best Internet. Pharmacy Store.
  • Buy Cheap order propecia online Now Best Internet. Safe And Secure Payment System.
  • Buy Cheap online pharmacys Online Cheap Online Pharmacy. Online Medical Shop.
  • Buy Cheap order zetia Now Best Drugstore. Cheap Prescription Drugs.
  • Buy Cheap cialis order Online Pharmacy Store. Internet Prices For cialis order!
  • Buy Cheap preventing arthritis Now Pharmacy Store. Top Online Pharmacy Supplier.
  • Buy Cheap levitra use Now 100% Satisfaction Guaranteed. Best Prices.
  • Buy Cheapest compare levitra Now Internet Prices For compare levitra! Low Prices.
  • Buy Cheap total health discount vitamins Online WorldWide Shipping. Cheap Online Pharmacy.
  • Buy Cheap new appetite suppressant Online Best Internet. Discount Online Pharmacy.
  • Buy Cheapest generic nexium Now Internet Prices For generic nexium! Low Prices.
  • Buy Cheapest sertraline drug Now Top Online Pharmacy. Best Drugstore.
  • Buy Cheapest propecia prescription Now Best Prices. Special Prices For propecia prescription!
  • Buy Cheapest cheap xanax next day delivery Online Best Drugstore. Cheap Online Pharmacy.