§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 team uses Lightbend Tech Hub to publish tutorials 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. The examples you can download cover the following topics:
§Java
Example | Download | Repository |
---|---|---|
Play Java gRPC Example | Download (zip) | Github |
REST API Example | Download (zip) | Github |
File Upload Example | Download (zip) | Github |
Forms Example | Download (zip) | Github |
JPA Example | Download (zip) | Github |
Ebean Example | Download (zip) | Github |
Websocket Example | Download (zip) | Github |
Chatroom using Websockets Example | Download (zip) | Github |
Streaming Example | Download (zip) | Github |
Compile Time Dependency Injection Example | Download (zip) | Github |
Using Dagger 2 for Compile Time DI | Download (zip) | Github |
§Scala
Example | Download | Repository |
---|---|---|
Play Scala gRPC Example | Download (zip) | Github |
REST API Example | Download (zip) | Github |
File Upload Example | Download (zip) | Github |
Forms Example | Download (zip) | Github |
Anorm Example | Download (zip) | Github |
Integrated Slick Example | Download (zip) | Github |
Isolated Slick Example | Download (zip) | Github |
Websocket Example | Download (zip) | Github |
Chatroom using Websockets Example | Download (zip) | Github |
Streaming Example | Download (zip) | Github |
Compile Time Dependency Injection Example | Download (zip) | Github |
Dependency Injection using Macwire Example | Download (zip) | Github |
Secure Session Example | Download (zip) | Github |
§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.6.x
§Play Framework Tutorials and other contents
- Running Play on GraalVM: Play’s core contributor Christian Schmitt explains how to run Play applications using GraalVM and the challenges and benefits of using GraalVM with Play.
- Getting Started With Play Framework: This DZone’s reference card shows the most basic concepts of Play in a resumed but very informative way.
- Play: The Missing Tutorial: In this tutorial series, Shekhar Gulati
shows how to build a blogging platform called blogy that you can use to write and publish blogs. - Our adventure using Play Framework with Kotlin: This article written by Antonio López Marín for Karumi details the steps necessary to write a Play application using Kotlin language.
- Add Authentication to Play Framework with OIDC and Okta: Matt Raible shows how easy it is to integrate Play with a modern authentication mechanism like OpenID Connect using play-pac4j.
- REST API using Play Framework with Java: This article shows how to create an application using Play Framework and Java with
GET
,POST
,PUT
andDELETE
APIs for CRUD operations. - RESTful APIs With the Play Framework - Part 1 & RESTful APIs With the Play Framework — Part 2: In this two part tutorial, Mercedes Wyss gives a look into how to set up your development environment using the Play framework, and how to get Play going on your machine, and later at creating RESTful APIs exploring how to handle JSON in your code.
- Creating forms on your Play application - Part 1 & Creating forms on your Play application - Part 2: Pedro Rijo goes from basic to advanced examples showing the helpers that Play provides when dealing with HTML forms, how to validate some inputs, and how does Play deals with those input errors.
- React with Play Framework 2.6.x: Yohan Gomez explains the pros and cons of different approaches when integrating React and Play, and later how to structure your project when using both. There are seed projects for both Java and Scala.
- Angular 6 with Play Framework 2.6.x: Again Yohan Gomez explains how to integrate Play and modern frontend frameworks, but this time with Angular 6. There are seed projects for both Java and Scala.
- Internationalization with Play Framework: Teena Vashist demonstrate how your application can support different languages using Play Framework 2.6.
- Authentication using Actions in Play Framework: Geetika Gupta demonstrates how to use Action Composition to handle authentication in Play applications.
- Streaming data from PostgreSQL using Akka Streams and Slick in Play Framework: In this blog post, Sidharth Khattri explains the process wherein you can stream data directly from PostgreSQL database using Scala Slick (which is Scala’s database access/query library) and Akka Streams.
- Stream a file to AWS S3 using Akka Streams (via Alpakka) in Play Framework: In this blog post Sidharth Khattri explains how a file can be streamed from a client (eg: browser) to Amazon S3 using Alpakka’s AWS S3 connector.
§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.
- Debug Play Application in IntelliJ IDE
- Debug Play Application in Eclipse IDE
- How Routing Works
- Add Support for MySQL in Play
- Include Bootstrap and jQuery
- Form Validations
- Creating Custom Error Pages
§Dependency Injection
- Dependency Injection in Play Framework using Scala by Krzysztof Pado.
§Akka Streams
- Akka Streams integration in Play Framework 2.5 by Loïc Descotte.
- Playing with Akka Streams and Twitter by Loïc Descotte.
§Database
- Play Database Application using Slick, Bootstrap: This is an example project for showcasing best practices and providing a seed for starting with Play & Slick, By Knoldus.
§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
- Making a REST API in Play, a multi-part guide using the Scala API, by the Lightbend Play Team.
- 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:
- Templates, Routes and AJAX
- Upgrading the Framework
- Database Access
- Async Futures and Actors
- Optimistic Future Composition
- React UI Coffeescript
- CSRF Protection
§Minimal Play
- A Play Application in 38 Lines by Lloyd Chan, showing a “Sinatra” style of Play application.
§Dependency Injection
- Playframework 2.4 Dependency Injection (DI) by Marius Soutier.
- Testing with Dependency Injection by Michael Pollmeier.
- Compile Time Dependency Injection with Play 2.4 by Loïc Descotte.
§REST APIs
Justin Rodenbostel of SPR Consulting also has two blog posts on building REST APIs in Play:
- Building a Simple REST API with Scala & Play! (PART 1)
- Building a Simple REST API with Scala & Play! (PART 2)
§Slick
- Play framework, Slick and MySQL Tutorial by Pedro Rijo.
§RethinkDB
§Forms
- How to add a form to a Play application by Chris Birchall of the Guardian.
§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.
- RequireJS Optimization with Play 2.1 and WebJars
- Intro to sbt-web
- Understanding sbt and sbt-web settings
- Play Angular Require Seed Updates
§React JS
- ReactJS Tutorial with Play, Scala and WebJars by Fabio Tiriticco.
- A basic example to render UI using ReactJS with Play 2.4.x, Scala and Anorm by Knoldus / activator template.
§2.3.x
§REST APIs
- Playing with Play Framework 2.3.x: REST, pipelines, and Scala by Sampson Oliver.
§Anorm
Knoldus has a nice series of blog posts on Anorm:
- Employee-Self-Service – Building Reactive Play application with Anorm SQL data access – (Part-1)
- Employee-Self-Service – Building Reactive Play application with Anorm SQL data access – (Part-2)
- Employee-Self-Service: Reactive and Non-Blocking Database Access using Play Framework and Anorm – (Part-3)
- Employee-Self-Service: Reactive and Non-Blocking Database Access using Play Framework and Anorm – (Part-4)
§Forms
- Example form including multiple checkboxes and selection by Philip Johnson.
- UX-friendly conditional form mapping in Play by Nick Tune.
§2.2.x
§Advanced Routing
- Advanced routing in Play Framework by James Roper.
- Play Routes – Part 1, Basics by Marius Soutier.
- Play Routes – Part 2, Advanced Use Cases by Marius Soutier.
§Path Bindables
- How to implement a custom PathBindable with Play 2 by Julien Richard-Foy.
§Templates
- Play Framework 2.0 Templates – Part 1, Parameters by Marius Soutier.
§User Interface
- Composite user interface without boilerplate using Play 2 by Julien Foy.
§Play in Practice
- Play in Practice by Will Sargent.
Next: Working with Play