Wern is a web developer from the Philippines. He loves building things for the web and sharing the things he has learned by writing in his blog. When he's not coding or learning something new, he enjoys watching anime and playing video games.

Wern's articles

  1. Create a Movie Recommendation App with Prediction.io – Implementation

    This entry is part 2 of 2 in the series Create a Movie Recommendation App

    In part one, we covered the basics of Prediction IO and installed its dependencies. In this part, we’re going to build the app.

    Importing Data from TMDB

    We will be importing the data using the Prediction IO SDK, so we first need to tell Flight to use it. In the beginning of your index.php file add the following code:

    <?php
    session_start(); //start a session
    require 'vendor/autoload.php'; //autoload dependencies
    
    use PredictionIO\PredictionIOClient; //import the prediction IO client

    Next, register the Prediction IO Client to Flight so that we can use it throughout our app:

    Flight::register('prediction', 'PredictionIO\PredictionIOClient');

    While we’re here let’s also register the MongoDB class so that we can query MongoDB later on:

    Flight::register('mdb', 'Mongo', array('mongodb://localhost'));

    Next, we map the factory method to a Flight method and call it prediction_client. We will be using this later on to make calls with the Prediction IO client.

  2. Create a Movie Recommendation App with Prediction.io – Setup

    This entry is part 1 of 2 in the series Create a Movie Recommendation App

    In this tutorial, I’m going to walk you through Prediction IO, an open-source machine learning server. It allows you to create applications that could do the following:

    • recommend items (e.g. movies, products, food)
    • predict user behavior
    • identify item similarity
    • rank items

    You can pretty much build any machine learning application with ease using Prediction IO. You don’t have to deal with numbers and algorithms and you can just concentrate on building the app itself.

    Installation

    The tutorial assumes your base OS is Linux. If this is not the case, please consider using Homestead Improved for a standardized and easy to use Vagrant box which gets you up and running with MySQL, PHP 5.6 and Nginx in under five minutes.

    The first thing that you need to do is to install Prediction IO. You can download Prediction IO from their downloads page. Once you’ve downloaded it, you can extract it to your preferred installation path. Prediction IO is now installed, but it needs the following dependencies to be installed first before you can use it:

    • Java (Version 6+)
    • MongoDB

    You can install these prerequisites through the provided setup script. Navigate to the root of your prediction IO installation path and execute the following command:

    bin/setup-vendors.sh

    That will install all the dependencies for you.

  3. Automate PHP with Phake – Real World Examples

    This entry is part 2 of 2 in the series Automating PHP with Phake

    In part one, we covered the basics of Phake and demonstrated ways of executing tasks with it, covering groups, dependencies, and arguments. In this part, we’ll look at some sample real world applications of Phake. Note that the following examples are largely based on things that I usually do manually that need some sort of automation.

    Uploading Files to Server

    Let’s start by writing a task that will upload files to an FTP server.

  4. Automate PHP with Phake – Introduction

    This entry is part 1 of 2 in the series Automating PHP with Phake

    As developers, we often have to do repetitive tasks such as updating the database structure, seeding the database, writing CRUD code, running tests, and uploading files to a server. Wouldn’t it be great if we could automate these mundane tasks and proceed with solving the more important problems such as making our app more secure or more usable to our users?

    Phake, an automation tool written for PHP, can do those tasks for you. If you’re familiar with Ruby, it’s basically a Rake clone. In this two-part series I’m going to walk you through integrating Phake into your workflow. I will walk you through the installation, some of the basics in using Phake and then finally some real-world examples.

    Installation

    Phake should be installed globally via Composer:

    composer global require 'jaz303/phake=*'

    This makes Phake accessible from any folder, and doesn’t require you to change your project’s composer.json file.

    If you don’t have access to the ‘composer’ command, install Composer globally.

  5. Database Versioning with DBV

    It’s good practice to always use a version control system in any of your projects. Be it a side-project in which you are the only developer, or a team project where five or more people are working on it together. But the idea of putting your database into version control isn’t really that widespread. Often times we take the database for granted.

    But like the source files in our project, the database is constantly changing too. That’s why we also need a way to track the changes that we have made and easily share it to other members of our team.

    In this article we will take a look at DBV, a database version control system written in PHP for MySQL databases so you need to have PHP and MySQL installed before you can use it, along with a web server like Apache or Nginx.

    An important note about this software is that it is not a stand-alone database version control system, because it needs a version control system such as Git, Mercurial or SVN for syncing changes with your team.

    Installing DBV

    To start working with DBV, first you have to download the installer from their website, extract it into your project directory then rename the resulting folder to dbv. This will give you the following path:

    my_project/dbv

    An alternative approach is just cloning from Github.

    DBV Configuration

    You can start configuring the options for DBV by creating a copy of the config.php.sample file and renaming it to config.php.

    The most important things to update here are the first two sections. Just substitute the values for my_username, my_password, my_database for the values in your current database configuration: