public function put($documentId, array $doc)
    {
        $context = array('http' => array());

        $context['http']['method'] = 'PUT';
        $context['http']['header'] = 'Content-Type: application/json';
        $context['http']['content'] = json_encode($doc);

        $rev = isset($doc['_rev']) ? '?rev=' . $doc['_rev'] : '';
        list($status, $response) = $this->sendRequest(urlencode($documentId) . $rev, $context);

        if ($status == 409) {
            throw new Exception\Conflict('PUT /' . $documentId . ' failed.');
        } elseif ($status != 201) {
            throw new Exception\Response('PUT /' . $documentId . ' - Unknown response status.');
        }

        if (isset($response['id'])) {
            return array('_id' => $response['id'], '_rev' => $response['rev']);
        } else {
            return $response;
        }
    }
public function put($documentId, array $doc)
    {
        $context = array('http' => array());

        $context['http']['method'] = 'PUT';
        $context['http']['header'] = 'Content-Type: application/json';
        $context['http']['content'] = json_encode($doc);

        $rev = isset($doc['_rev']) ? '?rev=' . $doc['_rev'] : '';
        list($status, $response) = $this->sendRequest(urlencode($documentId) . $rev, $context);

        if ($status == 409) {
            throw new Exception\Conflict('PUT /' . $documentId . ' failed.');
        } elseif ($status != 201) {
            throw new Exception\Response('PUT /' . $documentId . ' - Unknown response status.');
        }

        if (isset($response['id'])) {
            return array('_id' => $response['id'], '_rev' => $response['rev']);
        } else {
            return $response;
        }
    }
public function put ( $ documentId , array $ doc ) { $ context = array ( 'http' => array ( ) ) ; $ context [ 'http' ] [ 'method' ] = 'PUT' ; $ context [ 'http' ] [ 'header' ] = 'Content-Type: application/json' ; $ context [ 'http' ] [ 'content' ] = json_encode ( $ doc ) ; $ rev = isset ( $ doc [ '_rev' ] ) ? '?rev=' . $ doc [ '_rev' ] : '' ; list ( $ status , $ response ) = $ this -> sendRequest ( urlencode ( $ documentId ) . $ rev , $ context ) ; if ( $ status == 409 ) { throw new Exception \ Conflict ( 'PUT /' . $ documentId . ' failed.' ) ; } elseif ( $ status != 201 ) { throw new Exception \ Response ( 'PUT /' . $ documentId . ' - Unknown response status.' ) ; } if ( isset ( $ response [ 'id' ] ) ) { return array ( '_id' => $ response [ 'id' ] , '_rev' => $ response [ 'rev' ] ) ; } else { return $ response ; } }
Update or create a document by ID.
CouchDb recommends using PUT rather than POST where possible to avoid proxy issues.

@param string $documentId ID to update or create.
@param array $doc Document to store.
@link http://wiki.apache.org/couchdb/HTTP_Document_API#PUT
@throws \Chill\Exception\Conflict
@throws \Chill\Exception\Response
@return array
Update or create a document by ID . CouchDb recommends using PUT rather than POST where possible to avoid proxy issues .