skalmi/cakephp-diffbot-datasource

CakePHP DiffbotSource Plugin with DataSource

0.0.11 2014-12-11 14:14 UTC

This package is not auto-updated.

Last update: 2024-12-17 04:42:04 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

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