Back to Playframework

Play Tutorials

documentation/manual/tutorial/Tutorials.md

3.1.0-M921.7 KB
Original Source
<!--- Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> -->

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.

The play-samples GitHub repository offers Play examples that cover a huge number of cases. There you can find projects in Java, Scala and for multiple versions of Play. You can pick one that demonstrates functionality of interest to you. Make sure you have verified the [[requirements for running Play|Requirements]]. You can either clone the play-samples GitHub repository or download its contents, which include all samples, as a zip file. Alternatively, for a more streamlined option, you can download individual samples as zip files from the list below. This is recommended, as these zip files exclude unnecessary files for building and testing the samples.

Java

ExampleDownload
Play Java Hello World ExampleDownload (zip)
Play Java Starter ExampleDownload (zip)
Play Java gRPC ExampleDownload (zip)
REST API ExampleDownload (zip)
File Upload ExampleDownload (zip)
Forms ExampleDownload (zip)
JPA ExampleDownload (zip)
Ebean ExampleDownload (zip)
Websocket ExampleDownload (zip)
Chatroom using Websockets ExampleDownload (zip)
Streaming ExampleDownload (zip)
Compile Time Dependency Injection ExampleDownload (zip)
Using Dagger 2 for Compile Time DIDownload (zip)

Scala

ExampleDownload
Play Scala Hello World ExampleDownload (zip)
Play Scala Starter ExampleDownload (zip)
Play Scala gRPC ExampleDownload (zip)
REST API ExampleDownload (zip)
File Upload ExampleDownload (zip)
Forms ExampleDownload (zip)
Anorm ExampleDownload (zip)
Integrated Slick ExampleDownload (zip)
Isolated Slick ExampleDownload (zip)
Websocket ExampleDownload (zip)
Chatroom using Websockets ExampleDownload (zip)
Streaming ExampleDownload (zip)
Compile Time Dependency Injection ExampleDownload (zip)
Dependency Injection using Macwire ExampleDownload (zip)
Secure Session ExampleDownload (zip)
TLS ExampleDownload (zip)

Third Party Tutorials and Templates

The Play community also has a number of tutorials and templates that cover aspects of Play better 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.8.x

Play Framework Tutorials and other contents

  • Forms Tutorial in Play Framework: In this tutorial you will learn how to handle forms in Play Framework, complete with error handling and displaying in using the Twirl template engine.
  • Building a REST API in Play Framework: This article shows how to create an application using Play Framework and Java with GET, POST, PUT and DELETE APIs for CRUD operations.
  • Handling Exceptions and Errors in Play Framework: A tutorial on how to handle exceptions in Play Framework so that propper return codes are send back to the client with a response body that provides the needed information about the error.

2.6.x

Play Framework Tutorials and other contents

2.5.x

Play Framework Tutorial Video Series

A tutorial video series by Radix Code provides an initial overview to Play, walking through initial IDE setup, defining routes, creating a CRUD application, enabling ORM support, and customizing the views with bootstrap.

Dependency Injection

Akka Streams

Forms and Validators

  • Controller Forms: This provides examples of using forms and custom validators within a controller.
  • Json Validators: This guide lists methods of validating json against a customized case class or trait.

REST APIs

  • Play API REST Template by Adrianhurt: shows how to implement a complete Json RESTful API with some characteristics such as Authentication Token, pagination, filtering, sorting and searching and optional enveloping.

Sub-projects

  • Play Multidomain Seed by Adrianhurt: tries to be a skeleton for a simple multidomain project (www.myweb.com and admin.myweb.com). It shows you how to use subprojects for that and how to share common code. It is also ready to use with Webjars, CoffeeScript, LESS, RequireJS, assets Gzip and assets fingerprinting. Please, check the readme file for more details.
  • Play Multidomain Auth by Adrianhurt: this is a second part of play-multidomain-seed project. This project tries to be an example of how to implement an Authentication and Authorization layer using the Silhouette authentication library. It also uses Play-Bootstrap for easy template scaffolding.

Upgrading

  • Upgrading from Play 2.3 to Play 2.5 by Gregg Hernandez: Learn how to deal with common problems when upgrading to Play 2.5, including maintaining legacy behavior, transitioning to Akka Streams, and implementing compile-time dependency injection.

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

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