All Projects → tiaguinho → mongodb-cakephp3

tiaguinho / mongodb-cakephp3

Licence: MIT license
An Mongodb datasource for CakePHP 3.0

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to mongodb-cakephp3

Enum
Enumeration list for CakePHP 3
Stars: ✭ 27 (-6.9%)
Mutual labels:  cakephp, cakephp3
cakephp-api-pagination
📑 CakePHP 4 plugin that injects pagination information into API responses.
Stars: ✭ 39 (+34.48%)
Mutual labels:  cakephp, cakephp3
cakephp-mailgun
Mailgun plugin for CakePHP 3
Stars: ✭ 23 (-20.69%)
Mutual labels:  cakephp, cakephp3
auth
Auth objects for CakePHP
Stars: ✭ 28 (-3.45%)
Mutual labels:  cakephp, cakephp3
asset-mix
Provides helpers functions for CakePHP to use Laravel Mix.
Stars: ✭ 27 (-6.9%)
Mutual labels:  cakephp
cakephp-glide
CakePHP plugin for using Glide image manipulation library
Stars: ✭ 34 (+17.24%)
Mutual labels:  cakephp
cakephp-translate
A CakePHP plugin to manage translations of your static content the easy way via web backend.
Stars: ✭ 18 (-37.93%)
Mutual labels:  cakephp
spark-netflow
NetFlow data source for Spark SQL and DataFrames
Stars: ✭ 16 (-44.83%)
Mutual labels:  datasource
dynamic-datasource-starter
springboot 动态切换数据的基本思想与实现方法
Stars: ✭ 12 (-58.62%)
Mutual labels:  datasource
spark-hadoopoffice-ds
A Spark datasource for the HadoopOffice library
Stars: ✭ 36 (+24.14%)
Mutual labels:  datasource
TinyCoordinator
The Swift version of ThinningCoordinator focus on lighter view controllers.
Stars: ✭ 18 (-37.93%)
Mutual labels:  datasource
PHP-Frameworks-Bench
Popular PHP Frameworks Benchmark.
Stars: ✭ 28 (-3.45%)
Mutual labels:  cakephp
grafana-csv-plugin
CSV datasource for Grafana 6.x.x / 7.x.x
Stars: ✭ 33 (+13.79%)
Mutual labels:  datasource
puppet-jboss
Installs JBoss EAP and WildFly application servers and manage their resources and applications in either a domain or a stand-alone mode
Stars: ✭ 15 (-48.28%)
Mutual labels:  datasource
cakephp-sequence
CakePHP plugin for maintaining a contiguous sequence of records
Stars: ✭ 41 (+41.38%)
Mutual labels:  cakephp
Orderly
Default ordering for your CakePHP tables
Stars: ✭ 21 (-27.59%)
Mutual labels:  cakephp
assembler
Functional, type-safe, stateless reactive Java API for efficient implementation of the API Composition Pattern for querying/merging data from multiple datasources/services, with a specific focus on solving the N + 1 query problem
Stars: ✭ 102 (+251.72%)
Mutual labels:  datasource
Micro
🏎Fast diffing and type safe SwiftUI style data source for UICollectionView
Stars: ✭ 77 (+165.52%)
Mutual labels:  datasource
crud-json-api
Build advanced JSON API Servers with almost no code.
Stars: ✭ 47 (+62.07%)
Mutual labels:  cakephp
foodcoopshop
Open source software for food coops and local shops 🥕🍏 🧀
Stars: ✭ 60 (+106.9%)
Mutual labels:  cakephp

Slack

Mongodb for Cakephp3

An Mongodb datasource for CakePHP 3.5

Installing via composer

Install composer and run:

composer require hayko/mongodb dev-master

Connecting the Plugin to your application

add the following line in your config/bootstrap.php to tell your application to load the plugin:

Plugin::load('Hayko/Mongodb');

Defining a connection

Now, you need to set the connection in your config/app.php file:

 'Datasources' => [
    'default' => [
        'className' => 'Hayko\Mongodb\Database\Connection',
        'driver' => 'Hayko\Mongodb\Database\Driver\Mongodb',
        'persistent' => false,
        'host' => 'localhost',
        'port' => 27017,
        'login' => '',
        'password' => '',
        'database' => 'devmongo',
        'ssh_host' => '',
        'ssh_port' => 22,
        'ssh_user' => '',
        'ssh_password' => '',
        'ssh_pubkey_path' => '',
        'ssh_privatekey_path' => '',
        'ssh_pubkey_passphrase' => ''
    ],
],

SSH tunnel variables (starting with 'ssh_')

If you want to connect to MongoDB using a SSH tunnel, you need to set additional variables in your Datasource. Some variables are unnecessary, depending on how you intend to connect. IF you're connecting using a SSH key file, the ssh_pubkey_path and ssh_privatekey_path variables are necessary and the ssh_password variable is unnecessary. If you're connecting using a text-based password (which is not a wise idea), the reverse is true. The function needs, at minimum, ssh_host, ssh_user and one method of authentication to establish a SSH tunnel.

Models

After that, you need to load Hayko\Mongodb\ORM\Table in your tables class:

//src/Model/Table/YourTable.php

use Hayko\Mongodb\ORM\Table;

class CategoriesTable extends Table {

}

Observations

The function find() works only in the old fashion way. So, if you want to find something, you to do like the example:

$this->Categories->find('all', ['conditions' => ['name' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name LIKE' => 'teste']]);
$this->Categories->find('all', ['conditions' => ['name' => 'teste'], 'limit' => 3]);

You can also use the advanced conditions of MongoDB using the MongoDB\BSON namespace

$this->Categories->find('all', ['conditions' => [
    '_id' => new \MongoDB\BSON\ObjectId('5a7861909db0b47d605c3865'),
    'foo.bar' => new \MongoDB\BSON\Regex('^(foo|bar)?baz$', 'i')
]]);

LICENSE

The MIT License (MIT) Copyright (c) 2013

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].