Download the PHP package robsonvn/laravel-couchdb without Composer

On this page you can find all versions of the php package robsonvn/laravel-couchdb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-couchdb

Laravel CouchDB

Build Status StyleCI codecov.io

Laravel CouchDB is an Eloquent model and Query builder with support for CouchDB 2.x, using the original Laravel API. This library extends the original Laravel classes, so it uses exactly the same methods.

Good to know before using it

Table of contents

Installation

Installation using composer:

And add the service provider in config/app.php:

Laravel version Compatibility

For now, this project only works with Laravel 5.4.x

Configuration

Change your default database connection name in config/database.php:

And add a new couchdb connection:

And this on yours .env file

Please note, the database user must be an admin since this library creates indexes on the fly (design_docs)

You can read more about CouchDB Authorization here.

Eloquent

This package includes a CouchDB enabled Eloquent class that you can use to define models for corresponding collections.

Note that we did not tell Eloquent which collection to use for the Book model. Just like the original Eloquent, the lower-case, plural name of the class will be used as the collection name unless another name is explicitly specified. You may specify a custom collection (alias for table) by defining a collection property on your model:

Query Builder

The database driver plugs right into the original query builder. When using couchdb connections, you will be able to build fluent queries to perform database operations. For your convenience, there is a collection alias for table as well as some additional couchdb specific operators/operations.

If you did not change your default database connection, you will need to specify it when querying.

Read more about the query builder on http://laravel.com/docs/queries

Extensions

Auth

If you want to use Laravel's native Auth functionality, register this included service provider:

This service provider will slightly modify the internal DatabaseTokenRepository to add support for CouchDB based password reminders. If you don't use password reminders, you don't have to register this service provider and everything else should work just fine.

You also needs to extends the CouchDB Authenticatable class in your User class instead of the native one.

Queues

If you want to use CouchDB as your database backend, change the the driver in config/queue.php:

If you want to use CouchDB to handle failed jobs, change the database in config/queue.php:

And add the service provider in config/app.php:

Examples

Basic Usage

Retrieving All Models

Retrieving A Record By Primary Key

Wheres

Or Statements

And Statements

Using Where In With An Array

When using whereNotIn objects will be returned if the field is non existent. Combine with whereNotNull('age') to leave out those documents.

Using Where Between

Where null

Order By

Offset & Limit

Advanced Wheres

Like (case-sensitive)

Like (case-insensitive)

Incrementing or decrementing a value of a column

Perform increments or decrements (default 1) on specified attributes:

The number of updated objects is returned:

You may also specify additional columns to update:

Soft deleting

When soft deleting a model, it is not actually removed from your database. Instead, a deleted_at timestamp is set on the record. To enable soft deletes for a model, apply the SoftDeletingTrait to the model:

For more information check http://laravel.com/docs/eloquent#soft-deleting

CouchDB specific operators

Exists

Matches documents that have the specified field.

All

Matches arrays that contain all elements specified in the query.

Size

Selects documents if the array field is a specified size.

Regex

Selects documents where values match a specified regular expression.

NOTE: Mango query uses Erlang regular expression implementation.

Most selector expressions work exactly as you would expect for the given operator. The matching algorithms used by the $regex operator are currently based on the Perl Compatible Regular Expression (PCRE) library. However, not all of the PCRE library is implemented, and some parts of the $regex operator go beyond what PCRE offers. For more information about what is implemented, see the Erlang Regular Expression information http://erlang.org/doc/man/re.html.

Type

Selects documents if a field is of the specified type. Valid values are "null", "boolean", "number", "string", "array", and "object".

Mod

Performs a modulo operation on the value of a field and selects documents with a specified result.

Inserts, updates and deletes

Inserting, updating and deleting records works just like the original Eloquent.

Saving a new model

You may also use the create method to save a new model in a single line:

Updating a model

To update a model, you may retrieve it, change an attribute, and use the save method.

Deleting a model

To delete a model, simply call the delete method on the instance:

Or deleting a model by its key:

For more information about model manipulation, check http://laravel.com/docs/eloquent#insert-update-delete

Dates

Eloquent allows you to work with Carbon/DateTime object. Internally, these dates will be converted to a formated string 'yyyy-mm-dd H:i:s' when saved to the database. If you wish to use this functionality on non-default date fields you will need to manually specify them as described here: http://laravel.com/docs/eloquent#date-mutators

Example:

Which allows you to execute queries like:

Relations

Supported relations are:

Example:

And the inverse relation:

The belongsToMany relation will not use a pivot "table", but will push id's to a __related_ids__ attribute instead. This makes the second parameter for the belongsToMany method useless. If you want to define custom keys for your relation, set it to null:

Other relations are not yet supported, but may be added in the future. Read more about these relations on http://laravel.com/docs/eloquent#relationships

EmbedsMany Relations

If you want to embed models, rather than referencing them, you can use the embedsMany relation. This relation is similar to the hasMany relation, but embeds the models inside the parent object.

REMEMBER: these relations return Eloquent collections, they don't return query builder objects!

You access the embedded models through the dynamic property:

The inverse relation is automagically available, you don't need to define this reverse relation.

Inserting and updating embedded models works similar to the hasMany relation:

You can update embedded models using their save method:

You can remove an embedded model by using the destroy method on the relation, or the delete method on the model:

If you want to add or remove an embedded model, without touching the database, you can use the associate and dissociate methods. To eventually write the changes to the database, save the parent object:

Like other relations, embedsMany assumes the local key of the relationship based on the model name. You can override the default local key by passing a second argument to the embedsMany method:

Embedded relations will return a Collection of embedded items instead of a query builder. Check out the available operations here: https://laravel.com/docs/master/collections

EmbedsOne Relations

The embedsOne relation is similar to the EmbedsMany relation, but only embeds a single model.

You access the embedded models through the dynamic property:

Inserting and updating embedded models works similar to the hasOne relation:

You can update the embedded model using the save method:

You can replace the embedded model with a new model like this:

Raw Expressions

These expressions will be injected directly into the query.

You can also perform raw expressions on the internal CouchDBCollection object. If this is executed on the model class, it will return a collection of models. If this is executed on the query builder, it will return the original response.

The internal CouchDBClient can be accessed like this:

CouchDB Limitations

Limitations

TODO

Special Thanks

Fred Booking for supporting this project.

Jens Segers and the Laravel MongoDB contributors because many of the code and structure of this project came from there.


All versions of laravel-couchdb with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
illuminate/database Version 5.4.*
illuminate/support Version 5.4.*
illuminate/container Version 5.4.*
illuminate/events Version 5.4.*
doctrine/couchdb Version ^2.0.0-alpha1
adbario/php-dot-notation Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package robsonvn/laravel-couchdb contains the following files

Loading the files please wait ....