Use Phabricator for Code Reviews

Phabricator is an open source collection of web applications which makes it easier to scale software companies. It is currently available as a continuous release.

Phabricator

This article explains setting up phabricator tool to review code, track bugs, browse source, and much more. I will be setting up http://review.vnykmshr.com as we discuss various aspects of the tool.

Begin with, lets add a CNAME record to vnykmshr.com DNS.

review 10800 IN CNAME vnykmshr.com.

This allows us to setup phabricator at review.vnykmshr.com. Next, we will set phabricator up on nginx with php-fpm.

Pre-requisites - Install nginx web server, php5, php5-fpm, mysql-server if not already installed.

sudo apt-get install nginx php5 php5-fpm php5-mysql php5-cli php5-cgi mysql-server

Lets get phabricator and it's dependencies, first pick a install directory (say /var/www/review).

$ mkdir -p /var/www/review && cd /var/www/review/
/var/www/review/$ git clone git://github.com/facebook/libphutil.git
/var/www/review/$ git clone git://github.com/facebook/arcanist.git
/var/www/review/$ git clone git://github.com/facebook/phabricator.git

Phabricator runs faster with APC installed, optional, but strongly recommended.

sudo apt-get install libpcre3-dev php-pear
sudo pecl install apc

to verify, php5 -i | grep apc

Next, lets set up review.vnykmshr.com on nginx. Add the following server block to a file under /etc/nginx/sites-available/ and link it up from /etc/nginx/sites-enabled when ready.

server {
  server_name review.vnykmshr.com;

  root      /var/www/review/phabricator/webroot;
  try_files $uri $uri/ /index.php;

  location / {
    index   index.php;

    if ( !-f $request_filename )
    {
      rewrite ^/(.*)$ /index.php?__path__=/$1 last;
      break;
    }
  }

  location /index.php {
    fastcgi_pass   localhost:9000;
    fastcgi_index   index.php;

    #required if PHP was built with --enable-force-cgi-redirect
    fastcgi_param  REDIRECT_STATUS    200;

    #variables to make the $_SERVER populate in PHP
    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param  QUERY_STRING       $query_string;
    fastcgi_param  REQUEST_METHOD     $request_method;
    fastcgi_param  CONTENT_TYPE       $content_type;
    fastcgi_param  CONTENT_LENGTH     $content_length;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

    fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

    fastcgi_param  REMOTE_ADDR        $remote_addr;
  }
}

\m/

Vinayak Mishra

Vinayak Mishra, a Cricket Enthusiast with keen interest in web and mobile applications. Hails from Mithila, Nepal, married to Rani and dad to his bundle of joy Bunu. Lives in New Delhi, India. You can follow him on Twitter or check out his website, vnykmshr.com.