Installation of PhpSlim

Requirements

You do not need a webserver like Apache.

  • PHP version ≥ 5.1.2, CLI access
  • Java ≥ 6 for FitNesse

Install PhpSlim

All you need to do is download the phpslim.phar and put it into some directory either in your project or into a central path like /opt.

Prepare FitNesse

Now you need a FitNesse installation to make use of PhpSlim. Go to the download page, either download the latest fitnesse.jar from the RELEASE section or click on the EDGE: Latest Hudson build link and download the fitnesse.jar file from the Hudson page.

Put the fitnesse.jar file into some directory from where you want to start the FitNesse system.

Create a project directory

Now create an empty directory for your new PHP project. For this tutorial, I assume that your project directory is /path/to/project.

I prefer to keep my FitNesse wiki pages in my project directory. This allows me to keep the tests and the code synchronized under version control. You can take a look at this video by Uncle Bob.

Brett Schuchert describes an alternative way of using FitNesse as a central wiki server

Start FitNesse

On the console, change to the directory where you put the fitnesse.jar file. Then start FitNesse on port 8070 like this.

java -jar fitnesse.jar -e 0 -p 8070 -d /path/to/project

For more information on the command line options take a look at the Starting and Stopping FitNesse user guide.

You should now see the output

Unpacking new version of FitNesse resources.  Please be patient.
................................................................................
...
................................................................................
FitNesse (v20100403) Started...
    port:              8070
    root page:         fitnesse.wiki.FileSystemPage at /path/to/project/FitNesseRoot
    logger:            none
    authenticator:     fitnesse.authentication.PromiscuousAuthenticator
    html page factory: fitnesse.html.HtmlPageFactory
    page version expiration set to 0 days.

You will find, that FitNesse creates the directory FitNesseRoot in our project path. This directory contains a directory FitNesse with the user guide and more information about FitNesse.

You may delete the FitNesse sub directory, if you do not want to keep it under your project path.

The FitNesseRoot directory is the place, where the wiki pages for our tests will be stored.

Now direct your browser to http://localhost:8070 and you will see your local version of the FitNesse FrontPage.

Tell FitNesse about PhpSlim

You have to tell FitNesse, to use the PhpSlim server.

The appropriate place to tell FitNesse, how to call up PhpSlim is http://localhost:8070/root. This page is always parsed, when you run a test. Open this root page in your browser and click on Edit. Assuming that you saved phpslim.phar to /opt/phpslim.phar, enter the following in the editor text area.

!define TEST_RUNNER (/opt/phpslim.phar)
!define COMMAND_PATTERN (php %m /path/to/project/Slim)
!define TEST_SYSTEM (slim)

You need to replace /path/to/project with your actual path. The %m is replaced by the TEST_RUNNER and the parameter after %m defines the php include path.

If you saved phpslim.phar into /path/to/project/phpslim.phar you can define the TEST_RUNNER relative to FITNESSE_ROOTPATH. You can also define the include path relative to FITNESSE_ROOTPATH.

!define TEST_RUNNER (${FITNESSE_ROOTPATH}/phpslim.phar)
!define COMMAND_PATTERN (php %m ${FITNESSE_ROOTPATH}/Slim)
!define TEST_SYSTEM (slim)

These settings are described on the CustomizingTestExecution page of the User Guide.

Click on Save.

You can now write your first test.