Digital Sanctum

Personal blog of Shane Witbeck Tags · Archive · About

Play Framework 2 Tutorial: Introduction

How to create a simple Play Framework application and deploy it to Heroku. Helpful screenshots and complete source code is available for download.

Published: 26 May 2012

I’ve been putting off learning the Play Framework because I wasn’t sure it was going to be just another framework that’s here today and forgotten tomorrow. As of the time this post was written it seems that Play is not just another framework and is in fact gaining a lot of traction (especially since version 2.0). In fact it’s a framework that’s now supported by a couple of my favorite PaaS providers such as Heroku and CloudFoundry.

So here’s an introductory tutorial of how to get a basic “Hello World” app running and deployed to Heroku.


It’s assumed that you have the following installed and available on your workstation:

  1. install git
  2. install play
  3. install heroku toolbelt

Creating the app

We start by creating a very basic skeletal application. I’ve decided to name my app “finances”.

cd ~/projects (or wherever you’d like to create your new app)

new play app screenshot

Initialize git:

Updating the app

Beyond the skeleton app created via “play new finances”, here are some changes to make via your favorite text editor:

Create app/controllers/ with the following content:

Create app/views/index.scala.html

Create app/views/layout.scala.html

Update conf/routes

Update project/Build.scala (adding the mainLang argument to the PlayProject method)

Run and verify the app locally

Deploying to Heroku

Now that you’ve verified the app locally, you can deploy it to Heroku:

For more information about running play on Heroku, see the Play documentation or the Heroku documentation.

Download Source

You can download or fork the complete source for this tutorial at GitHub.