PHP7 + REST + Couchbase

Hello!

I got this: The requested URL /default/search was not found on this server.
Is that a connection problem?

    private function search($request) {
        $cluster = new CouchbaseCluster("http://127.0.0.1:8091/", "root", "123456");
        $bucket = $cluster->openBucket("default");
        $query = CouchbaseN1qlQuery::fromString('SELECT * FROM '.$request->getResource().' WHERE '.self::queryParams($request->getParameters()));
        $rows = $bucket->query($query);
        return $rows;
    }

Could someone help me?

Thanks a lot!

@jkjunior, could you enable logging and paste them here?
http://developer.couchbase.com/documentation/server/current/sdk/php/collecting-information-and-logging.html

Before it, i got this:

Fatal error:  Uncaught Error: Class 'CouchbaseCluster' not found in /var/www/html/aula8/resource_controller.php:27
Stack trace:
#0 /var/www/html/aula8/resource_controller.php(22): ResourceController->search(Object(Request))
#1 /var/www/html/aula8/request_controller.php(37): ResourceController->treat_request(Object(Request))
#2 /var/www/html/aula8/index.php(6): RequestController->execute()
#3 {main}
  thrown in /var/www/html/aula8/resource_controller.php on line 27

Its not recognizing the CouchbaseCluster Class. I installed everything right. I dont understand. Do i have to include something?

Thanks for your attention!

could you show output of

php -i | grep -A3 couchbase

and also make sure you have enabled extension in one of the ini files reported by

php --ini
``

I'm assuming here that PHP CLI use the same config set as your web version

you have to load extension=json.so before couchbase also

Which one do i have to insert the extension=couchbase.so and extension=json.so in ini files?

yes,

extension=json.so
extension=couchbase.so

first json and then couchbase

Ok, but which ini file?

Now im getting this:
Fatal error: Uncaught CouchbaseException: LCB_HTTP_ERROR: HTTP Operation failed. Inspect status code for details in [CouchbaseNative]/CouchbaseBucket.class.php:316 Stack trace: #0 [CouchbaseNative]/CouchbaseBucket.class.php(316): _CouchbaseBucket->n1ql_request('{"statement":"S...', true) #1 [CouchbaseNative]/CouchbaseBucket.class.php(378): CouchbaseBucket->_n1ql(Object(CouchbaseN1qlQuery), false) #2 /var/www/html/aula8/resource_controller.php(32): CouchbaseBucket->query(Object(CouchbaseN1qlQuery)) #3 /var/www/html/aula8/resource_controller.php(22): ResourceController->search(Object(Request)) #4 /var/www/html/aula8/request_controller.php(37): ResourceController->treat_request(Object(Request)) #5 /var/www/html/aula8/index.php(6): RequestController->execute() #6 {main} thrown in [CouchbaseNative]/CouchbaseBucket.class.php on line 316

Thanks.

Could you enable and capture logs?

http://developer.couchbase.com/documentation/server/current/sdk/php/collecting-information-and-logging.html

I tried that already, but its not working…

-t php, means identifier php, are you sure your are running it with such identifier? maybe set error_log to some file? like /tmp/php.log

@avsej resolved, but I got another problem.

When i do this: $cluster = new CouchbaseCluster('127.0.0.1:8091', 'root', '123456'); $bucket = $cluster->openBucket('teste', 'teste'); $res = $bucket->get('2');

It works fine.

When i do this: $cluster = new CouchbaseCluster('127.0.0.1:8091', 'root', '123456'); $bucket = $cluster->openBucket('teste', 'teste'); $query = CouchbaseN1qlQuery::fromString('SELECT * FROM teste'); $rows = $bucket->query($query);

It dosent work and replies this: Uncaught CouchbaseException: LCB_HTTP_ERROR: HTTP Operation failed. Inspect status code for details in [CouchbaseNative]/CouchbaseBucket.class.php:316 Stack trace: #0 [CouchbaseNative]/CouchbaseBucket.class.php(316): _CouchbaseBucket->n1ql_request('{"statement":"S...', true) #1 [CouchbaseNative]/CouchbaseBucket.class.php(378): CouchbaseBucket->_n1ql(Object(CouchbaseN1qlQuery), false) #2 /var/www/html/aula8/resource_controller.php(34): CouchbaseBucket->query(Object(CouchbaseN1qlQuery))

does it write anything in logs?