blog

  • Home
  • blog
  • PredictionIO and Lumen: Building a Movie Recommendation App

PredictionIO and Lumen: Building a Movie Recommendation App

In the intro, we covered the basics of PredictionIO and installed its dependencies. In this part, we’re going to build the movie recommendation app.

Final app screenshot

Environment Config File

Inside your app directory, create a .env file and add the following configuration:

APP_ENV=local
APP_DEBUG=true
APP_KEY=some-random-key

PIO_KEY=your-pio-app-key
TMDB_KEY=your-tmdb-api-key

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=database

Make sure to replace the value of APP_KEY with a unique random key. Since we’re using Lumen, you can generate one by executing php artisan key:generate. Also, replace the value for PIO_KEY with the key of the PredictionIO app that you created, and the TMDB_KEY with the API key provided by the TMDB website.

Importing Data from TMDB

We will be importing the data using the PredictionIO SDK, so we first need to tell Lumen to use it. Create a Classes directory under lumen/app. Then inside it, create a Pio.php file and add the following code.

<?php
namespace AppClasses;

use predictionioEventClient;
use predictionioEngineClient;

class Pio
{

    public function eventClient()
    {

        $pio_accesskey = env('PIO_KEY');
        $pio_eventserver = 'http://127.0.0.1:7070';

        return new EventClient($pio_accesskey, $pio_eventserver);

    }

    public function predictionClient()
    {

        $pio_predictionserver = 'http://127.0.0.1:8192';

        return new EngineClient($pio_predictionserver);

    }

}

This class will serve as a container for the PredictionIO event client and engine client. This way, we don’t have to instantiate those classes every time we need to use them.

Continue reading %PredictionIO and Lumen: Building a Movie Recommendation App%

LEAVE A REPLY