Complete Cassandra guide for Cassandra beginners with PHP Demo App

Complete Cassandra guide for Cassandra beginners.
So for the past few days I had been trying to get Cassandra running on my PC, I looked upon a lot of resources, got the help but couldn’t get a test app in PHP so decided to make one. Now I have made that test Application so I think I must share this with you.
But before this we must have a little knowledge of Cassandra. So
What is Cassandra?
From Cassandra’s Wiki
Cassandra is a highly scalable, eventually consistent, distributed, structured key-value store.
Yes Cassandra is a nosql solution to save your data in hash maps. It not a traditional relational DBMS rather it is an alternative to Relational DBMSs like MySQL, SQL Server, Oracle, Postgresql and many others.
Who Uses Cassandra:
To get a fair idea of the power of Cassandra I think I must share with you some of the Users of Cassandra. Here is the list
• Facebook
• Digg
• Twitter
• Redit
• App Scale
How to get Cassandra Running on Windows:
Pre Req: java must be installed and value of the environment variable “JAVA_HOME” must be set to its JRE Directory (in my case it is “C:\Program Files\Java\jre6”)
1. Get the latest binaries from”
2. Extract from Downloaded Archives to a folder say “Cassandra”(I’ll use this name in future)
3. Make three New Folders anywhere in your directory structure with names commitlog, data, saved cache.
4. Go to extracted archive and navigate to folder named “conf”
5. Open the file named “cassandra.yaml” in your favorite text editor.
6. In the “Cassandra.yaml” Set the values of
“data_file_directories” to the path of newly created “data” folder.
“commitlog_directory” to the path of newly created “commitlog” folder.
“saved_caches_directory” to the path of newly created “saved cache” folder.
So my values in “cassandra.yaml” look like this:
data_file_directories: C:\cassandra-data\data
commitlog_directory: C:\cassandra-data\commitlog
saved_caches_directory: C:\cassandra-data\saved cache
7. Add new environment variable “CASSANDRA_HOME” and set its value to the path of your Cassandra folder (Google to
know how to set environment variable).
8. Open cmd and navigate to the bin in your “Cassandra” folder
9. Run this command here “cassandra.bat”and your server will be running.
10. Open another cmd and run the command “Cassandra-cli –h localhost” and this must connect to your Cassandra
11. If you see a message like “Connected to: Test Clusrer on localhost/9160” you are with me up till this point and
your Cassandra is running perfectly.
12. Run these commands on your client one by one
• Create keyspace testApp;
• Create column family Users;

Cassandra Data Model:
To understand how Data is actually modeled in Cassandra I would recommend you to go through these links.

My PHP Test App:
Note: From here this article assumes that you have average knowledge of PHP.
Cassandra offers different high level clients to interact with Cassandra for different technologies. You can have a look on these here:

My Test Application is developed using “PHPCassa” a high level client for PHP. What you need to do to run this app is fairly simple.
Pre Reqs: PHP Development Environment must be installed (xampp is recommended).
1. Download my source code from:
2. Extract from the archive anywhere in your directory structure.
3. Copy this folder to the www root of apache server i.e. the htdocs directory(in my case its C:\xampp\htdocs\).
4. Run Index.php in the application folder from your browser.
5. And you are all done.
Note: Application is coded very simply, I don’t feel any average PHP Programmer should have any problem
understanding the code.
Any Queries or Problems?
You can ask right here in the comments. I’ll try to answer the question within my domain of understanding.