Documentation

You are viewing the documentation for the 2.5.12 release in the 2.5.x series of releases. The latest stable release series is 3.0.x.

§Play Tutorials

Play’s documentation shows the available features and how to use them, but the documentation will not show how to create an application from start to finish. This is where tutorials and examples come in.

Tutorials and examples are useful for showing a single application at work, especially when it comes to integrating with other systems such as databases or Javascript frameworks.

§Play Maintained Seeds and Example Templates

This section covers the core tutorials and examples from Play. These are maintained by the core Play team, and so will be based on the latest Play release.

All of the following projects can be downloaded as example projects from the download page.

§Play Seeds

There are two Play Seeds that are designed expressly for getting started with new Play applications. They contain a hello world controller and view template, filters, and nothing else.

If you have sbt 0.13.13 or higher installed, you can create your own Play project using sbt new
using a minimal giter8 template (roughly like a maven archetype). This is a good choice if you already know Play and want to create a new project immediately.

Type g8Scaffold form from sbt to create the scaffold controller, template and tests needed to process a form.

§Java

sbt new playframework/play-java-seed.g8

§Scala

sbt new playframework/play-scala-seed.g8

§Play Starter Projects

For people using Play for the first time, there is a starter project which introduces Play with some sample controllers and components.

or you can download it as an example project from the download page.

§Database / ORM Access

Play is unopinionated about database access, and integrates with many object relational layers (ORMs). There is out of the box support for Anorm, EBean, Slick, and JPA, but many customers use NoSQL or REST layers and there are many examples of Play using other ORMs not mentioned here.

§Slick

Slick is a Functional Relational Mapping (FRM) library for Scala that makes it easy to work with relational databases. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can also use SQL directly. Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.

§JPA

This is a example template showing Play with Java Persistence API (JPA), using Hibernate Entity Manager. It is included in the Play project itself.

§Anorm

This is an example template showing Play with Anorm using Play’s Anorm Integration. It also uses Play-Bootstrap for easy template scaffolding.

§EBean

This is an example template that uses EBean using Play’s Ebean integration. It also uses Play-Bootstrap for easy template scaffolding.

§Comet / Server Sent Events (SSE)

This is an example template that shows streaming responses through Comet or Server Sent Events, using Akka Streams:

§WebSocket

This is an example template that shows bidirectional streaming through the WebSocket API, using Akka Streams:

§Cryptography

This is an example template showing how to encrypt and sign data securely with Kalium:

§Compile Time Dependency Injection

Compile time dependency injection can be done in Play in a number of different DI frameworks.

There are two examples shown here, but there are other compile time DI frameworks such as Scaldi, which has Play integration built in, and Dagger 2, which is written in Java.

§Manual Compile Time Dependency Injection

This is an example template showing how to use manual compile time dependency injection and manual routing with the SIRD router, useful for minimal REST APIs and people used to Spray style routing:

§Macwire Dependency Injection

This is an example template showing compile time dependency injection using Macwire.

§Third Party Tutorials and Templates

The Play community also has a number of tutorials and templates that cover aspects of Play than the documentation can, or has a different angle. Templates listed here are not maintained by the Play team, and so may be out of date.

This is an incomplete list of several helpful blog posts, and because some of the blog posts have been written a while ago, this section is organized by Play version.

§2.5.x

§Dependency Injection

§Akka Streams

§Database

§2.4.x

§Semisafe

Semisafe has an excellent series on Play in general:

§Minimal Play

§Dependency Injection

§REST APIs

Justin Rodenbostel of SPR Consulting also has two blog posts on building REST APIs in Play:

§Slick

§RethinkDB

§Forms

§EmberJS

§AngularJS, RequireJS and sbt-web

Marius Soutier has an excellent series on setting up a Javascript interface using AngularJS with Play and sbt-web. It was originally written for Play 2.1.x, but has been updated for Play 2.4.x.

§React JS

§2.3.x

§REST APIs

§Anorm

Knoldus has a nice series of blog posts on Anorm:

§Forms

§2.2.x

§Advanced Routing

§Path Bindables

§Templates

§User Interface

§Play in Practice

Next: Working with Play