predictionio/predictionio-bundle

Symfony2 Bundle for PredictionIO API PHP Client

Installs: 100

Dependents: 0

Stars: 1

Watchers: 1

Language: PHP

0.1 2013-10-30 22:19 UTC

README

Tests are not yet mocked and still depend on my local PredictionIO vagrant :| (fixing in next release)

Installation

Step 1) Include the bundle in your composer json

"require" :  {
    // ...
    "predictionio/predictionio-bundle": "dev-master",
}

Step 2) Register the bundle in your AppKernel

<?php
    // app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new PredictionIO\PredictionIOBundle\PredictionIOBundle(),
        );
        // ...
    }

Step 3) Configure the bundle

# app/config/config.yml
// ...
prediction_io:
    apiurl: http://localhost:8000
    appkey: INSERT_APPKEY_HERE

User Service

$userService = $container->get('prediction_io.user_service');

// Create user
$userService->createUser($id);

// Get user
$user = $userService->getUser($id);

// Delete user
$userService->deleteUser($user);

// Record action
$userService->recordAction($user, $item, $action);

// Get recommendations
$userService->getRecommendations($user, $engine, $count);

Item Service

$itemService = $container->get('prediction_io.item_service');

// Create item
$itemService->createItem($id);

// Get item
$item = $itemService->getUser($id);

// Delete item
$itemService->deleteItem($item);

// Get similar items
$itemService->getSimilarItems($item, $engine, $count);