Well a PHP, Node.J and Golang developer for DataSift and Hootware actually!

Category Archives: PHP

I have worked at DataSift since the beginning of 2011 and a lot has changed since then. We were around 15 employees and all based in a small office in Reading. Since then we have expanded like crazy and have 120 employees spread over offices in Reading, San Francisco and New York.

So what do we do? We are the only independent reseller of social data in the world. We ingest data from tons of sources and that list is expanding all the time, for instance we are one of a handful of companies in the world that has access to firehoses from Twitter, Tumblr, WordPress, Disqus and many more. These streams give us every single public tweet/post/photo/reblog in real-time, equating to tens of thousands of pieces of data per second! Most of these sources are in real-time and we help brands, agencies, researchers, analysts and many other types of companies, access all this data to get more information on what their customers, competitors and audiences are doing. This is all in real-time with sub-second latency from end to end. Some great use cases:

Using social media data to help make casting decisions for major movie productions

If you are reading this post then you are either curious about what it’s about, you are investigating using PHP + Oracle on CentOS and building your own PHP RPM, or you’re familiar with the your RPM install complaining about libclntsh.so.11.1. This post should hopefully help you out.

Oracle Instant Client RPM

The first thing to note is that the RPM’s that Oracle supply will work fine when building PHP and setting the –with-pdo-oci=instantclient,/usr/,11.2 flag. But as soon as you try to install PHP and it brings in the Instant Client dependency, or if it is already installed you will see the following error:

Requires: libclntsh.so.11.1()(64bit)

You may well, like me, spend hours investigating why this occurs especially when

From the title of this post you might think, why are you doing this? What self-respecting software engineer wants to connect from a Linux distro to a Microsoft SQL Server instance? Well, never you mind!! Quit being nosey!! I thought I’d share my experience of trying to do this, partly to share the knowledge and partly to remind myself in a few years when I need to upgrade or revisit my code. It was an “interesting” and not at all frustrating experience…

Word of warning. You’ll never have as good an experience connecting from Linux to SQL Server as you would with PHP running on windows. This is the best solution that I could find without resorting to using Windows ew!

FreeTDS

FreeTDS is a library and a few binaries that allow you to connect to SQL Server and Sybase instances. It is available in most package manager repos. For instance I tried both Ubuntu (apt) and CentOS (yum). All you need to do is install the devel package as we’ll be building PHP from source.

Ubuntu

sudo apt-get install freetds-dev libxml2-dev

CentOS

sudo yum install freetds-devel libxml2-devel

PHP

At the time of writing this I am migrating from php 5.3 to php 5.5. So I’ll give you instructions for both version. The first thing to note is that you need to build PHP yourself are there are several configure flags that need to be set. So lets get on and install it.

Get the source

Configure

Now that we have the source and we’re in the correct directory we need to configure our PHP install. We need to enable a both PDO support and the “dblib” PDO driver, which will be using our FreeTDS library under-the-hood. Please not this will not enable the mssql_* functions, it will just enable us to connect to a SQL Server instance using PDO classes/methods.

./configure --with-pdo-dblib

If you build PHP yourself normally you’ll probably have other configure flags to set. This shouldn’t conflict with any of them and can safely be added to your existing list of arguments.