skalmi / cakephp-diffbot-datasource
CakePHP DiffbotSource Plugin with DataSource
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- composer/installers: *
- imsamurai/http-source: >=1.0.0
README
CakePHP DiffbotSource is DataSource Plugin for Diffbot
Installation
Step 1: Clone or download HttpSource
Step 2: Clone or download to Plugin/DiffbotSource
cd my_cake_app/app git://github.com/skalmi/CakePHP-DiffbotSource-Datasource.git Plugin/DiffbotSource
or if you use git add as submodule:
cd my_cake_app
git submodule add "git://github.com/skalmi/CakePHP-DiffbotSource-Datasource.git" "app/Plugin/DiffbotSource"
then update submodules:
git submodule init
git submodule update
Step 3: Add your configuration to database.php
and set it to the model
:: database.php ::
public $diffbot = array( 'datasource' => 'DiffbotSource.Http/DiffbotSource', 'host' => 'example.com', 'port' => 'some port' ); public $diffbotTest = array( 'datasource' => 'DiffbotSource.Http/DiffbotSource', 'host' => 'api.diffbot.com', 'prefix' => '', 'port' => 80, 'timeout' => 5 );
Then make model
:: Diffbot.php ::
public $useDbConfig = 'diffbot'; public $useTable = '<desired endpoint, for ex: "article">';
Step 4: Load plugin
:: bootstrap.php ::
CakePlugin::load('HttpSource', array('bootstrap' => true, 'routes' => true)); CakePlugin::load('DiffbotSource', array('bootstrap' => false, 'routes' => false));
#Tests
To run tests add and fill $diffbotTest in database.php
#Usage
You can use elasticsearch almost as db tables:
$this->Diffbot->setSource('article'); $params = array( 'conditions' => array( 'query' => array( "term" => array("title" => "apple") ) ), 'fields' => array('title', 'rank'), 'order' => array('rank' => 'desc'), 'offset' => 2 ); $result = $this->Diffbot->find('first', $params);
#Documentation
Please read HttpSource Plugin README