PHP code example of fredpalas / couchbase-bundle

1. Go to this page and download the library: Download fredpalas/couchbase-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fredpalas / couchbase-bundle example snippets


// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...        
        new Apperturedev\CouchbaseBundle\CouchbaseBundle(),
    );
}


//in action throw container

public function indexAction()
{
    /** @var Apperturedev\CouchbaseBundle\Classes\CouchbaseORM $couchbase editor Helper */
    $couchbase = $this->get('couchbase');
    
    $entity = New Entity();
    // do anything
    
    // save
    $couchbase->save($entity);
    
    $entity->getId();  // Will set the id Automatic
    
    $repository = $couchbase->getRepository('Bundle:Entity');
    // get data
    $entity1 = $repository->getById(1);
    
    /** For Run Couchbase View you need to run bin/console couchbase:generate:view Bundle:Entity */
    /** Fixing a bug for moving old version class */
    // country example           
    $query = $repository->get('country');
    $query->key('Spain')->order(\CouchbaseViewQuery::ORDER_ASCENDING)->limit(6);

    // Will return a array if more than 1 or the object if is 1
    $country = $repository->execute($query);
}