As part of my work as a CLOCK developer, I’ll be using MongoDB. This is new tech for me so I thought I’d have a dabble in it before things get heavy on the CLOCK project. This post is a bit of an overview of my thoughts and findings.
The what with the who?!
MongoDB is, from the MongoDB website:
MongoDB (from “humongous”) is a scalable, high-performance, open source NoSQL database.
In a nutshell, it’s a less structured way of storing data. The benefits I can see is that entries are stored in a JSON style document format, which immediately makes it (from my relatively naive outlook on open data) a great way of storing data for retrieving in apps or providing via an API.
Getting it running
Getting the actual database server running was a relatively straightforward task. Download the binaries, unzip to a sensible folder on my PC, fire up the server and then open the shell. You can connect to databases from here, start meddling with data and kind of see what all the fuss is about. I must admit, I’m not always comfortable setting up new server environments, as there always seems to be something to go a bit wrong with them, but I was up and running, inserting and querying from the console in about 5mins. Dead. Easy.
Mongo provides a quickstart guide for all platforms. For the record, I’m a Windows user.
Onwards – to PHP!
Obviously, as I’m going to be developing apps on Mongo, I need it to be accessible from my development environment. Again, as a Windows user, I run a WAMP stack. In fact I use the very convenient WAMPserver to set up my stack which is an exe that does all the hard work for you.
So, we need the right DLL to get PHP talking to the Mongo server. In theory, just go to the Github driver repository, grab the latest version, stick it in your php extensions folder, add extension=php_mongo.dll to your php.ini file, restart the server and you should be good to go.
Unfortunately, this was where the issues started arising. My WAMP stack was simply not picking up the Mongo dll. Eventually, after some digging around in the error logs, I found out the little nugget of information that the php_mongo.dll is not compatible with a 64bit set up. Which is what I was running. So, I installed a fresh, 32bit server, fired that up, installed the dll and – works! Hurrah!
So, word of advice, if you want to develop using Mongo as a back end in PHP, you need to be running a 32bit version on Windows.
So, the server is all up and running, the next step is to start playing with applications – look out for a future blog post updating on this!