Skip to content

Commit 212841e

Browse files
author
Marc Juchli
committed
Merge branch 'release/1.0'
2 parents 33f6fa1 + 96e488f commit 212841e

File tree

5 files changed

+169
-2
lines changed

5 files changed

+169
-2
lines changed

Api/PredictionIO.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PredictionIO {
1818

1919
protected $apiUrl;
2020

21-
public function __construct($appKey, $apiUrl){
21+
public function __construct($appKey, $apiUrl = null){
2222
$this->appKey = $appKey;
2323
$this->apiUrl = $apiUrl;
2424
}
@@ -31,4 +31,12 @@ public function getClient(){
3131
)
3232
);
3333
}
34+
35+
public function getAppKey(){
36+
return $this->appKey;
37+
}
38+
39+
public function getApiUrl(){
40+
return $this->apiUrl;
41+
}
3442
}

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
CodagPredictionIOBundle
2+
==================
3+
4+
This bundle provides an [PredictionIO](http://prediction.io/) integration for your Symfony2 Project.
5+
6+
[![Build Status](https://travis-ci.org/Codag/PredictionIOBundle.png?branch=master)](https://travis-ci.org/Codag/PredictionIOBundle)
7+
[![Total Downloads](https://poser.pugx.org/codag/predictionio-bundle/downloads.png)](https://packagist.org/packages/codag/predictionio-bundle)
8+
[![Latest Stable Version](https://poser.pugx.org/codag/predictionio-bundle/v/stable.png)](https://packagist.org/packages/codag/predictionio-bundle)
9+
10+
**PredictionIO Methods Supported**
11+
12+
This Bundle is just a wrapper for the [PredictionIO-PHP-SDK](https://github.com/PredictionIO/PredictionIO-PHP-SDK) and will support all methods provided in the SDK.
13+
14+
## Installation
15+
16+
1. Add CodagPredictionIOBundle to your composer.json
17+
2. Enable the bundle
18+
3. Configure the bundle
19+
20+
### Step 1: Add CodagAlchemyApiBundle to your composer.json
21+
```js
22+
{
23+
"require": {
24+
"codag/predictionio-bundle": "dev-master"
25+
}
26+
}
27+
```
28+
29+
Update your project dependencies:
30+
```bash
31+
php composer.phar update codag/predictionio-bundle
32+
```
33+
34+
### Step 2: Enable the bundle
35+
```php
36+
<?php
37+
// app/AppKernel.php
38+
39+
public function registerBundles()
40+
{
41+
$bundles = array(
42+
// ...
43+
new Codag\PredictionIOBundle\CodagPredictionIOBundle(),
44+
);
45+
}
46+
```
47+
48+
### Step 3: Configure the bundle
49+
50+
Yml configuration:
51+
```yaml
52+
# app/config/config.yml
53+
54+
codag_prediction_io:
55+
app_key: Your App Key
56+
api_url: Your Api Url # Optional
57+
58+
```
59+
60+
## Usage
61+
This bundle provides the service `codag.predictionio`
62+
```php
63+
<?php
64+
$client = $this->get('codag.predictionio')->getClient();
65+
```
66+
67+
For further implementation examples please see also our [Sandbox](https://github.com/Codag/PredictionIOBundle-Sandbox).
68+
69+
##Contribute
70+
71+
If the bundle doesn't allow you to customize an option, I invite you to fork the project, create a feature branch, and send a pull request.
72+
73+
To ensure a consistent code base, you should make sure the code follows
74+
the [Coding Standards](http://symfony.com/doc/current/contributing/code/standards.html).
75+
76+
77+
##License
78+
79+
This bundle is under the MIT license. See the complete license [here](https://github.com/Codag/PredictionIOBundle/blob/master/Resources/meta/LICENSE).
80+

Resources/config/services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</parameters>
1212

1313
<services>
14-
<service id="predictionio" class="%codag_prediction_io.service.class%">
14+
<service id="codag.predictionio" class="%codag_prediction_io.service.class%">
1515
<argument>%prediction_io.app_key%</argument>
1616
<argument>%prediction_io.api_url%</argument>
1717
</service>

Tests/Api/PredictionIOTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PredictionIO package.
5+
*
6+
* (c) Marc Juchli <mail@marcjuch.li>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Codag\PredictionIOBundle\Tests\Api;
13+
14+
use Codag\PredictionIOBundle\Api\PredictionIO;
15+
16+
/**
17+
* Test PredictionIO Api Class
18+
*
19+
* @author Marc Juchli <mj@codag.ch>
20+
*/
21+
22+
class PredictionIOTest extends \PHPUnit_Framework_TestCase
23+
{
24+
/**
25+
* Test Client
26+
*
27+
* @covers Codag\PredictionIOBundle\Api\PredictionIO::getClient()
28+
*/
29+
public function testGetClient()
30+
{
31+
$client = new PredictionIO('testkey');
32+
$client = $client->getClient();
33+
34+
$client->identify('username');
35+
36+
$this->assertEquals('username', $client->getIdentity());
37+
}
38+
39+
/**
40+
* Test App Key
41+
*
42+
* @covers Codag\PredictionIOBundle\Api\PredictionIO::getAppKey()
43+
*/
44+
public function testGetAppKey(){
45+
$api = new PredictionIO('testkey');
46+
47+
$this->assertEquals('testkey', $api->getAppKey());
48+
}
49+
50+
/**
51+
* Test Api Url
52+
*
53+
* @covers Codag\PredictionIOBundle\Api\PredictionIO::getApiUrl()
54+
*/
55+
public function testGetApiUrl(){
56+
$api = new PredictionIO('testkey', 'testurl');
57+
58+
$this->assertEquals('testurl', $api->getApiUrl());
59+
}
60+
61+
}

Tests/bootstrap.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/*
3+
* This file is part of the PredictionIO package.
4+
*
5+
* (c) Marc Juchli <mail@marcjuch.li>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Codag\PredictionIOBundle\Tests;
12+
13+
$file = __DIR__.'/../vendor/autoload.php';
14+
if (!file_exists($file)) {
15+
throw new RuntimeException('Install dependencies to run test suite.');
16+
}
17+
18+
require_once $file;

0 commit comments

Comments
 (0)