Setting up Couchbase PHP-SDK with XAMPP on Windows

Getting up and running with PHP on Windows has always been quite easy due to
XAMPP. It provides everything needed
to get started quickly and build something using a default stack available
everywhere. A lot of people get (or got) started this way, including me. But now
that MySQL, PHP, and Apache are setup maybe it’s time to try something new. For
me it’s been a while since I ran a setup like this and so I thought it’s worth
documenting the process.

Getting all the pieces

First of all you’ll need:

  • XAMPP for all your PHP and
    Apache needs, so install at least PHP and Apache
  • Couchbase, remember that you can try
    out the Enterprise version for development for free.
  • Couchbase-PHP-SDK
    XAMPP uses thread safe PHP so make sure you download the correct version
    (either x86 or x64 Thread Safe) for your environment.

Getting everything installed

For Couchbase and XAMPP you basically follow the instructions on the screen to
get it up and running, and make sure you configure Couchbase as well at the end
by visiting the web interface. Now all there is left is
moving the PHP stuff into place, which is probably the most complicated part of
a really easy setup. The zip downloaded from the windows PECL
page
contains 2 dll files,
libcouchbase.dll and php_couchbase.dll which need to be moved in the right
place. First to make php find libcouchbase it’s needs to be present c:apachebinlibcouchbase.dll and to make sure you can also use
php from the command line also copy it to c:xamppphplibcouchbase.dll and
add the XAMPP PHP to your PATH by going to Control Panel -> System and Security
-> Advanced System Settings -> Environment
Variables and edit the PATH
variable by appending c:YOUR XAMPP DIRECTORYphp. And that’s it you are
now ready to use Couchbase in XAMPP, by adding the extension to php.ini, so just add

https://gist.github.com/sideshowcoder/df131b67c173066291c3.js

Try it out!

Create a new PHP file at c:YOUR XAMPP DIRECTORYhtdocscb-test.php containing

https://gist.github.com/sideshowcoder/047d7989ad77e2b955e1.js

and open it in your browser to make apache run
it
you should now see the result in your browser.

cb-test-result

you can also use the command line of course.

cb-test-cmd

The end!

OK so you are now ready to use Couchbase from PHP, and if you need any help and
are in London this week stop by the Couchbase Developer Day as part of Big Data
Week
,
or even if you don’t still you should still stop by.

EDIT

You should also checkout Trond Norbye’s Blog basically describing the same setup.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s