PredictionIO PHP SDK
Clone or download
dszeto [PIO-163] Travis fixes
Also include ASF license fixes and PSR-2
Latest commit f1e33f3 Sep 14, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples [PIO-163] Travis fixes Sep 13, 2018
src/predictionio [PIO-163] Travis fixes Sep 13, 2018
tests/Unit [PIO-163] Travis fixes Sep 13, 2018
.gitignore [PIO-163] Stack upgrade and doc fix Sep 11, 2018
.travis.yml [PIO-163] Travis fixes Sep 13, 2018
CREDITS Doc updates Oct 26, 2017
LICENSE Doc updates Oct 26, 2017
NOTICE Doc updates Oct 26, 2017
README.md [PIO-163] Stack upgrade and doc fix Sep 11, 2018
build.xml [PIO-163] Travis fixes Sep 13, 2018
composer.json [PIO-163] Travis fixes Sep 13, 2018
composer.lock [PIO-163] Travis fixes Sep 13, 2018
phpunit.xml.dist [PIO-163] Travis fixes Sep 13, 2018

README.md

Apache PredictionIO PHP SDK

Build Status

Prerequisites

Note: This SDK only supports Apache PredictionIO version 0.8.2 or higher.

Getting Started

The easiest way to install PredictionIO PHP client is to use Composer.

  1. predictionio is available on Packagist and can be installed using Composer:

     composer require predictionio/predictionio
    
  2. Include Composer's autoloader in your PHP code

     require_once("vendor/autoload.php");
    

Usage

This package is a web service client based on Guzzle. A few quick examples are shown below.

Instantiate PredictionIO API Event Client

use predictionio\EventClient;
$accessKey = 'j4jIdbq59JsF2f4CXwwkIiVHNFnyNvWXqMqXxcIbQDqFRz5K0fe9e3QfqjKwvW3O';
$client = new EventClient($accessKey, 'http://localhost:7070');

Set a User Record from Your App

// assume you have a user with user ID 5
$response = $client->setUser(5);

Set an Item Record from Your App

// assume you have a book with ID 'bookId1' and we assign 1 as the type ID for book
$response = $client->setItem('bookId1', array('itypes' => 1));

Import a User Action (View) form Your App

// assume this user has viewed this book item
$client->recordUserActionOnItem('view', 5, 'bookId1');

Retrieving Prediction Result

// assume you have created an itemrank engine on localhost:8000
// we try to get ranking of 5 items (item IDs: 1, 2, 3, 4, 5) for a user (user ID 7)

$engineClient = new EngineClient('http://localhost:8000');
$response = $engineClient->sendQuery(array('uid'=>7, 'iids'=>array(1,2,3,4,5)));

print_r($response);

Bugs and Feature Requests

Use Apache JIRA to report bugs or request new features.

Community

Keep track of development and community news.

Contributing

Read the Contribute Code page.

License

Apache PredictionIO is under Apache 2 license.