Clone wiki

sproot / Getting Started

1. Prerequisites

Install Java

  1. Download Java (JDK) from and install it
  2. Put path to java (path_to_jdk) in environment variable JAVA_HOME

Install PHP

If you didn't install PHP yet, let's do it. Version of PHP should be >= 5.4.0

Install Apache Thrift Compiler (just 4th instruction of this list is needed for Production Environment! All other items just for development process)


  1. Download Thrift compiler version 0.9.1 from
  2. Put path to thrift-0.9.1.exe in environment variable THRIFT_HOME (for example "C:\Apache\thrift-0.9.1\bin")
  3. Download thrift-0.9.1.tar.gz from
  4. Unpack thrift-0.9.1.tar.gz and copy PHP related libs to the root of your application. For example:
copy thrift-0.9.1\lib\php\lib\Thrift %applicationFolder


  1. Download thrift-0.9.1.tar.gz from
  2. Build Thrift compiler as described here:
  3. Put path to thrift compiler executable in environment variable THRIFT_HOME (for example 'export THRIFT_HOME=/usr/local/bin')
  4. Copy PHP related libs from unpacked thrift-0.9.1.tar.gz to the root of your application. For example:
cp -r thrift-0.9.1/lib/php/lib/Thrift $applicationFolder

2. Deploy

You have two options: download zip distributive or build from source

Using zip archived distributive

  1. Download latest release from Downloads page
  2. Unpack zip archive

Building from source

  1. Install Apache Maven from
  2. Clone repo 'hg clone'
  3. Run 'mvn clean install' from root folder
  4. Take zip archive from 'target' folder
  5. Unpack it where you need to deploy Sproot

3. Configure

How to make a configuration file for your cluster you can find on configuration page.

When configuration file is ready, save it with name 'definition.xml' and put in $deploymentFolder/sproot-grid/config, where deploymentFolder - is the folder where you unpacked distributive.

4. Generate application-specific code

Since Sproot is designed to be aware of your data model, it has to generate appropriate transport objects, mappers, your data model as Java classes etc. It allows to avoid delays, because there is no need to analyze data objects at runtime, all the analysis is done at compile time.

If your 'definition.xml' already in $deploymentFolder/sproot-grid/config then you can generate application-specific code (both PHP and Java) using build script:

1) cd $deploymentFolder/sproot-grid/scripts

where deploymentFolder - is the folder where you unpacked distributive.





5. Start cluster

Every node will join cluster automatically in case configuration file is correct. To start node you should:

1) cd $deploymentFolder/sproot-grid/scripts

2) nodeId memorySize

where: nodeId -- integer value. Must match with id from <nodes/> section of definition.xml file. Every node will write its own log file which name depends on its type and id. For example "service-1.log" of "storageOnly-4.log"

memorySize -- size of memory node will use. You can specify it in megabytes or gigabytes

For example: 1 512m
run.cmd 1 2g

6. Work with Sproot

1) On the step 4 you have generated client PHP sources. So it's time to copy them from $deploymentFolder/sproot-grid/php to the root of your application. Please copy whole folder $deploymentFolder/sproot-grid/php/org. For example (for Linux):

cp -r $deploymentFolder/sproot-grid/php/org $applicationFolder

2) Start one or more nodes of cluster as described on the step 5

3) Use Sproot inside of your application. Sample application:

    require_once 'org/sproot_grid/SprootClient.php';
    require_once 'some/package/User.php';

    use org\sproot_grid\SprootClient;
    use some\package\User;

    $client = new SprootClient('localhost', 12345);
    echo $client -> cacheSize('user-cache');

    $user = new User();

    $client->put('user-cache', '1234', $user);

    echo $client->cacheSize('user-cache');

Full API is described here