How to create a view with PHP SDK?

Hi,

I think I’ve read documentation about creating a view from a SDK. I just could not find it anymore.

I’ve looked into method signatures of PHP SDK, but I don’t see any method that’s related to creating a view.

Is it possible to create a view from PHP SDK?

Hey moon0326,

Take a look at the API Reference and the CouchbaseBucket::manager function!

Cheers, Brett

Thank you brett19. I will look into that.

brett19, what API reference are we talking about? I don’t see SDK API reference. I can only find rest api references on http://docs.couchbase.com/admin/admin/REST/rest-bucket-intro.html

Hey moon0326,

Take a look here for the API Reference for the PHP SDK!
http://docs.couchbase.com/sdk-api/couchbase-php-client-2.0.5/

Cheers, Brett

Thank you brett19! Have a nice one!

@brett19

I finally had a chance to play with methods in the CouchbaseBucketManager class. Is there a tutorial for the class?

I could not find a way to add a view into a document. The problem was that ‘getDesignDocument’ simply returns an array. There’s no method for views.

Also, creating a design document creates a production design document.

  1. How can I create a view into a design document?
  2. How can I create a dev view?

Hey moon0326,

In Couchbase Server, there is no way to individually modify views, you must instead modify the design document as a whole which contains multiple views. Use the upsertDesignDocument or insertDesignDocument methods to do this.

Cheers, Brett

Thank you. I figured out, but it would be nice if there’s an official page with examples for any other future users.