Cassandra DataStax PHP Extension Setup

General Docs
DataStax PHP Driver

DataStax Driver PHP Docs

Native Linux
Follow DataStax linux installation steps (after installing dependencies). It works if you have conventional setup. You will need to install a lot of c++ development libraries for the compilation to work. Running a package manager install for a popular application build-tools should give you everything you need. I used…

sudo apt-get install build-essential
apt-get build-dep nginx
apt-get install php5-dev

Make sure to add cassandra to php.ini
; DataStax PHP Driver


For MAMP we need to hack the extension compilation scripts to point to the correct php directories. If you don’t you’ll get an an error when php starts up (enable startup error displays in php.ini) like this…

MacBook-Pro:code User$ php -v

Warning: PHP Startup: cassandra: Unable to initialize module
Module compiled with module API=20100525
PHP    compiled with module API=20131226
These options need to match
 in Unknown on line 0
PHP 5.6.2 (cli) (built: Oct 20 2014 16:21:27) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

This is bcs we’re trying to use php that’s linked in MAMP (/Applications/MAMP/bin/php), but the module was compiled using the OSX php installation (/usr/bin/php).. and they’re different versions.

The fix is to download the correct php version source and make sure the module compilation uses the correct version’s source.
This link outlines compiling cassandra php extensions with correct source.

I also made sym-links for php, php-config, and phpize like this example.
This is some general background information on compiling php extensions on alternative configurations.

I also edit the ext/ script with the following code…

echo "Compiling and installing the extension..."
phpdir=/Applications/MAMP/bin/php/php5.6.2 {{put in your correct php version directory}}


echo ./configure --with-php-config=$phpdir/bin/php-config --with-cassandra=$builddir --with-libdir=lib
LIBS="-lssl -lz -luv -lm -lstdc++" LDFLAGS="-L$builddir/lib" ./configure --with-cassandra=$builddir --with-libdir=lib --with-php-config=$phpdir/bin/php-config
make install

rm -Rf /tmp/php-driver-installation

Also don’t forget to do a clean between code changes

make clean


Add New WordPress User using only database

INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('newadmin', MD5('pass123'), 'firstname lastname', '', '0');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');

How to Add an Admin account in WordPress via MySQL

Laravel Stuff

Architecture Concepts (Laravel Docs)

Architecture of Laravel Applications


ajax post security in laravel? (Stack Exchange)

Multiple DB Connections in Laravel

How to use multiple database in Laravel

Multiple database connections in the same Laravel project

Laravel 5 multiple database connection.

Changing Eloquent models database connection at runtime

Specifying DB Connections on Laravel

Raw Queries in Laravel w/ parameters

Select with DB::raw() – make your database work

How to bind parameters to a raw DB query in Laravel that’s used on a model?