PHP code example of gorse / php-gorse

1. Go to this page and download the library: Download gorse/php-gorse library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gorse / php-gorse example snippets


$client = new Gorse("http://127.0.0.1:8088/", "api_key");

$user = new User("100", ["gender" => "M", "age" => "25"], "my_comment");
$rowsAffected = $client->insertUser($user);

$item = new Item(
    "2000", 
    true, 
    ["embedding" => [0.1, 0.2, 0.3]], 
    ["Comedy", "Animation"], 
    "2022-11-20T13:55:27Z", 
    "Minions (2015)"
);
$rowsAffected = $client->insertItem($item);

$feedback = [
    new Feedback("read", "100", "2000", 1.0, "2022-11-20T13:55:27Z"),
    new Feedback("read", "100", "2001", 1.0, "2022-11-20T13:55:27Z"),
];
$rowsAffected = $client->insertFeedback($feedback);

$items = $client->getRecommend('100', 10);
bash
composer