couchbase.php

INI entries:

  • couchbase.log_level (string), default: "WARN"

    controls amount of information, the module will send to PHP error log. Accepts the following values in order of increasing verbosity: "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE".

  • couchbase.encoder.format (string), default: "json"

    selects serialization format for default encoder (\Couchbase\defaultEncoder). Accepts the following values:

    • "json" - encodes objects and arrays as JSON object (using json_encode()), primitives written in stringified form, which is allowed for most of the JSON parsers as valid values. For empty arrays JSON array preferred, if it is necessary, use new stdClass() to persist empty JSON object. Note, that only JSON format considered supported by all Couchbase SDKs, everything else is private implementation (i.e. "php" format won't be readable by .NET SDK).
    • "php" - uses PHP serialize() method to encode the document.
    • "igbinary" - uses pecl/igbinary to encode the document in even more efficient than "php" format. Might not be available, if the Couchbase PHP SDK didn't find it during build phase, in this case constant \Couchbase\HAVE_IGBINARY will be false.
  • couchbase.encoder.compression (string), default: "none"

    selects compression algorithm. Also see related compression options below. Accepts the following values:

    • "fastlz" - uses FastLZ algorithm. The module might be configured to use system fastlz library during build, othewise vendored version will be used. This algorithm is always available.
    • "zlib" - uses compression implemented by libz. Might not be available, if the system didn't have libz headers during build phase. In this case \Couchbase\HAVE_ZLIB will be false.
    • "off" or "none" - compression will be disabled, but the library will still read compressed values.
  • couchbase.encoder.compression_threshold (long), default: 0

    controls minimum size of the document value in bytes to use compression. For example, if threshold 100 bytes, and the document size is 50, compression will be disabled for this particular document.

  • couchbase.encoder.compression_factor (float), default: 0.0

    controls the minimum ratio of the result value and original document value to proceed with persisting compressed bytes. For example, the original document consists of 100 bytes. In this case factor 1.0 will require compressor to yield values not larger than 100 bytes (100/1.0), and 1.5 -- not larger than 66 bytes (100/1.5).

  • couchbase.decoder.json_arrays (boolean), default: false

    controls the form of the documents, returned by the server if they were in JSON format. When true, it will generate arrays of arrays, otherwise instances of stdClass.

  • couchbase.pool.max_idle_time_sec (long), default: 60

    controls the maximum interval the underlying connection object could be idle, i.e. without any data/query operations. All connections which idle more than this interval will be closed automatically. Cleanup function executed after each request using RSHUTDOWN hook.

Interfaces

Authenticator Interface of authentication containers.
ViewQueryEncodable Common interface for all View queries
SearchQueryPart Common interface for all classes, which could be used as a body of SearchQuery
SearchFacet Common interface for all search facets

Classes

Exception Exception represeting all errors generated by the extension
Document Represents Couchbase Document, which stores metadata and the value.
DocumentFragment A fragment of a JSON Document returned by the sub-document API.
Cluster Represents a Couchbase Server Cluster.
ClusterManager Provides management capabilities for a Couchbase Server Cluster
UserSettings Represents settings for new/updated user.
Bucket Represents connection to the Couchbase Server
BucketManager Provides management capabilities for the Couchbase Bucket
ClassicAuthenticator Authenticator based on login/password credentials.
PasswordAuthenticator Authenticator based on RBAC feature of Couchbase Server 5+.
MutationToken An object which contains meta information of the document needed to enforce query consistency.
MutationState Container for mutation tokens.
ViewQuery Represents regular Couchbase Map/Reduce View query
SpatialViewQuery Represents spatial Couchbase Map/Reduce View query
N1qlQuery Represents a N1QL query
N1qlIndex Represents N1QL index definition
LookupInBuilder A builder for subdocument lookups. In order to perform the final set of operations, use the execute() method.
MutateInBuilder A builder for subdocument mutations. In order to perform the final set of operations, use the execute() method.
SearchQuery Represents full text search query
BooleanFieldSearchQuery A FTS query that queries fields explicitly indexed as boolean.
BooleanSearchQuery A compound FTS query that allows various combinations of sub-queries.
ConjunctionSearchQuery A compound FTS query that performs a logical AND between all its sub-queries (conjunction).
DisjunctionSearchQuery A compound FTS query that performs a logical OR between all its sub-queries (disjunction). It requires that a minimum of the queries match. The minimum is configurable (default 1).
DateRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
NumericRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
DocIdSearchQuery A FTS query that matches on Couchbase document IDs. Useful to restrict the search space to a list of keys (by using this in a compound query).
MatchAllSearchQuery A FTS query that matches all indexed documents (usually for debugging purposes).
MatchNoneSearchQuery A FTS query that matches 0 document (usually for debugging purposes).
MatchPhraseSearchQuery A FTS query that matches several given terms (a "phrase"), applying further processing like analyzers to them.
MatchSearchQuery A FTS query that matches a given term, applying further processing to it like analyzers, stemming and even #fuzziness(int).
PhraseSearchQuery A FTS query that matches several terms (a "phrase") as is. The order of the terms mater and no further processing is applied to them, so they must appear in the index exactly as provided. Usually for debugging purposes, prefer MatchPhraseQuery.
RegexpSearchQuery A FTS query that allows for simple matching of regular expressions.
WildcardSearchQuery A FTS query that allows for simple matching using wildcard characters (* and ?).
PrefixSearchQuery A FTS query that allows for simple matching on a given prefix.
QueryStringSearchQuery A FTS query that performs a search according to the "string query" syntax.
TermSearchQuery A facet that gives the number of occurrences of the most recurring terms in all hits.
TermRangeSearchQuery A FTS query that matches documents on a range of values. At least one bound is required, and the inclusiveness of each bound can be configured.
GeoDistanceSearchQuery A FTS query that finds all matches from a given location (point) within the given distance.
GeoBoundingBoxSearchQuery A FTS query which allows to match geo bounding boxes.
TermSearchFacet A facet that gives the number of occurrences of the most recurring terms in all hits.
DateRangeSearchFacet A facet that categorizes hits inside date ranges (or buckets) provided by the user.
NumericRangeSearchFacet A facet that categorizes hits into numerical ranges (or buckets) provided by the user.
SearchSort Base class for all FTS sort options in querying.
SearchSortId Sort by the document identifier.
SearchSortScore Sort by the hit score.
SearchSortField Sort by a field in the hits.
SearchSortGeoDistance Sort by a location and unit in the hits.
AnalyticsQuery Represents a Analytics query (currently experimental support).

Constants

HAVE_IGBINARY

HAVE_IGBINARY

If igbinary extension was not found during build phase this constant will store 0

HAVE_ZLIB

HAVE_ZLIB

If libz headers was not found during build phase this constant will store 0

ENCODER_FORMAT_JSON

ENCODER_FORMAT_JSON

Encodes documents as JSON objects (see INI section for details)

ENCODER_FORMAT_IGBINARY

ENCODER_FORMAT_IGBINARY

Encodes documents using pecl/igbinary encoder (see INI section for details)

ENCODER_FORMAT_PHP

ENCODER_FORMAT_PHP

Encodes documents using PHP serialize() (see INI section for details)

ENCODER_COMPRESSION_NONE

ENCODER_COMPRESSION_NONE

Do not use compression for the documents

ENCODER_COMPRESSION_ZLIB

ENCODER_COMPRESSION_ZLIB

Use zlib compressor for the documents

ENCODER_COMPRESSION_FASTLZ

ENCODER_COMPRESSION_FASTLZ

Use FastLZ compressor for the documents

Functions

fastlzCompress()

fastlzCompress(string  $data) : string

Compress input using FastLZ algorithm.

Parameters

string $data

original data

Returns

string —

compressed binary string

fastlzDecompress()

fastlzDecompress(string  $data) : string

Decompress input using FastLZ algorithm.

Parameters

string $data

compressed binary string

Returns

string —

original data

zlibCompress()

zlibCompress(string  $data) : string

Compress input using zlib. Raises Exception when extension compiled without zlib support.

Parameters

string $data

original data

Returns

string —

compressed binary string

zlibDecompress()

zlibDecompress(string  $data) : string

Compress input using zlib. Raises Exception when extension compiled without zlib support.

Parameters

string $data

compressed binary string

Returns

string —

original data

passthruDecoder()

passthruDecoder(string  $bytes, integer  $flags, integer  $datatype) : string

Returns value as it received from the server without any transformations.

It is useful for debug purpose to inspect bare value.

Parameters

string $bytes
integer $flags
integer $datatype

Returns

string —

Document as it received from the Couchbase.

Examples

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$bucket = $cluster->openBucket("default");
$bucket->setTranscoder("\\Couchbase\\defaultEncoder", "\\Couchbase\\passthruDecoder");
$bucket->upsert("foo", ["bar" => "baz"]);
$value = $bucket->get("foo")->value;
var_dump($value);
// => string(13) "{"bar":"baz"}"

passthruEncoder()

passthruEncoder(string  $value) : array

Returns the value, which has been passed and zero as flags and datatype.

It is useful for debug purposes, or when the value known to be a string, otherwise behavior is not defined (most likely it will generate error).

Parameters

string $value

document to be stored in the Couchbase

Returns

array —

Array with three values: [bytes, 0, 0]

defaultDecoder()

defaultDecoder(string  $bytes, integer  $flags, integer  $datatype) : mixed

Decodes value using \Couchbase\basicDecoderV1.

It passes couchbase.decoder.* INI properties as $options.

Parameters

string $bytes

Binary string received from the Couchbase, which contains encoded document

integer $flags

Flags which describes document encoding

integer $datatype

Extra field for datatype (not used at the moment)

Returns

mixed —

Decoded document object

defaultEncoder()

defaultEncoder(mixed  $value) : array

Encodes value using \Couchbase\basicDecoderV1.

It passes couchbase.encoder.* INI properties as $options.

Parameters

mixed $value

document to be stored in the Couchbase

Returns

array —

Array with three values: [bytes, flags, datatype]

basicDecoderV1()

basicDecoderV1(string  $bytes, integer  $flags, integer  $datatype, array  $options) : mixed

Decodes value according to Common Flags (RFC-20)

Parameters

string $bytes

Binary string received from the Couchbase, which contains encoded document

integer $flags

Flags which describes document encoding

integer $datatype

Extra field for datatype (not used at the moment)

array $options

Returns

mixed —

Decoded document object

basicEncoderV1()

basicEncoderV1(mixed  $value, array  $options) : array

Encodes value according to Common Flags (RFC-20)

Parameters

mixed $value

document to be stored in the Couchbase

array $options

Encoder options (see detailed description in INI section)

  • "sertype" (default: \Couchbase::ENCODER_FORMAT_JSON) encoding format to use
  • "cmprtype" (default: \Couchbase::ENCODER_COMPRESSION_NONE) compression type
  • "cmprthresh" (default: 0) compression threshold
  • "cmprfactor" (default: 0) compression factor

Returns

array —

Array with three values: [bytes, flags, datatype]