This is a pre-alpha version of an alternative ORM for CakePHP 3.0 using Elastic Search as its backend. It is currently under development and is only being used to test the interfaces exposed in CakePHP 3.0.
You can find the documentation for the plugin in the Cake Book.
You can install ElasticSearch into your project using
composer. For existing applications you can add the
following to your composer.json
file:
"require": {
"cakephp/elastic-search": "dev-master"
}
And run php composer.phar update
After installing, you should tell your application to load the plugin:
// in config/bootstrap.php
Plugin::load('Cake/ElasticSearch');
// If you want the plugin to automatically configure the Elastic model provider
// and FormHelper do the following:
Plugin::load('Cake/ElasticSearch', ['bootstrap' => true]);
Before you can do any work with elasticsearch models, you'll need to define a connection:
// in config/app.php
'Datasources' => [
// other datasources
'elastic' => [
'className' => 'Cake\ElasticSearch\Datasource\Connection',
'driver' => 'Cake\ElasticSearch\Datasource\Connection',
'host' => '127.0.0.1',
'port' => 9200,
'index' => 'my_apps_index',
],
]
Type objects are the equivalent of ORM\Table
instances in elastic search. You can
use the TypeRegistry
factory to get instances, much like TableRegistry
:
use Cake\ElasticSearch\TypeRegistry;
$comments = TypeRegistry::get('Comments');
Assuming you have PHPUnit installed system wide using one of the methods stated here, you can run the tests for CakePHP by doing the following:
- Copy
phpunit.xml.dist
tophpunit.xml
- Run
phpunit