Sri Harsha Sri Harsha - 6 months ago 93
PHP Question

Need help to install C SDK and PHP SDK for couchbase server 4.0.0 for UBUNTU 14.0

I have recently started working on couchbase with laravel 5.2 on UBUNTU 14.04 OS. After I installed everything, I am able to see couchbase admin home page but could not able to access it from my code. Below are the steps I followed. Can someone please check and suggest if I miss anything.

1) Downloaded and installed couchbase server 4.0.0 successfully.

2) Downloaded C SDK as mentioned below



wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
echo "deb http://packages.couchbase.com/ubuntu trusty trusty/main" >> /etc/apt/sources.list.d/couchbase.list
apt-get update
sudo apt-get install libcouchbase2-core libcouchbase2-libevent libcouchbase-dev





Then installed PHP SDK using PECL



sudo pecl install couchbase





4) After everything got installed, I have opened my composer.json file in my laravel project and added below line



"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"ytake/laravel-couchbase": "^0.2.0"
},





Then ran composer update.

5) My config/databse.php settings



'couchbase' => [
'driver' => 'couchbase',
'host' => 'http://localhost',
'user' => 'admin',
'password' => 'admin123',
'bucket' => 'laravel',
'persist_conn' => true,
'display_limit' => 20,





6)Tried to access records from "laravel" bucket.

Homecontroller:



<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;

class HomeController extends Controller {

public function index() {



\DB::connection('couchbase')
->table('laravel')->get();

// $cb = new Couchbase("http://localhost:8091/", "admin", "admin123", "laravel");
// $cb->set("a", 101);
// var_dump($cb->get("a"));
//
// $cluster = new CouchbaseCluster('http://127.0.0.1:8091');
// $bucket = $cluster->openBucket('laravel');
// $bucket->insert('a', 101);
// var_dump($bucket->get('a'));
}

}





Issue:#1 There I am getting "FatalErrorException in CouchbaseConnector.php line 35:Class 'CouchbaseCluster' not found".

Issue:#2 I am not able to see "Couchbase" in phpinfo();

Answer

This issue got resolved after I add couchbase.ini file in below location. /etc/php5/cli/conf.d/

20-couchbase.ini

; Enable couchbase extension module
extension = json.so
extension = couchbase.so

Comments