Play Framework Tutorials
In this detailed Resource page, we feature an abundance of Play Framework Tutorials!
Play Framework is an open-source web application framework, written in Scala and also usable from other programming languages that are compiled to Bytecode, e.g. Java, which follows the model–view–controller (MVC) architectural pattern. It aims to optimize developer productivity by using convention over configuration, hot code reloading and display of errors in the browser.
Support for the Scala programming language has been available since version 1.1 of the framework. In version 2.0, the framework core was rewritten in Scala. Build and deployment was migrated to SBT, and templates use Scala instead of Apache Groovy.
Play is heavily inspired by ASP.NET MVC, Ruby on Rails and Django and is similar to this family of frameworks. Play web applications can be written in Scala or Java, in an environment that may be less Java Enterprise Edition-centric. Play uses no Java EE constraints. This can make Play simpler to develop compared to other Java-centric platforms.
If you wish to build up your Play Framework knowledge first, check out our The Pros and Cons of Play and Grails Java Framework.
Play Framework Tutorials – Getting Started
Simple examples on how to use Play Framework
- Play! Framework Hello World Example
We are going to develop a series of Scala Web Applications or Microservices using Play Framework. This is our first post in this series. In this post, we feature a comprehensive Play! Framework Hello World Example. We are going to develop our old style, to learn new concepts on “HelloWorld” example using Play Framework, Scala Language and SBT build tool.
- Play! Framework Session Example
Today, on most web applications, there is data we need to be sent across multiple http requests while the user has a browser tab open. A lot of different approaches were made, such as cookies and headers forwarding. To solve this problem, play applications now have a powerful tool: Sessions and Flash scope.
- Play! Framework Security Example
In this example, we’ll write a login page, and forbid access to secured pages to users which are not logged in. Then we’ll configure security headers, such as: X-Frame-Options, X-XSS-Protection, X-Content-Type-Options, X-Permitted-Cross-Domain-Policies and Content-Security-Policy. And finally, we’ll configure CORS.
- Play! Framework Logging Example
Logging is a really important feature every application must have. Without it, it’s nearly impossible to know what your application is doing, how long does it take it, if it is failing, and if it is, why. With this in mind, play added logging support to it’s framework, using logback as logging implementation, and giving access to it through the Logger class.
- Play! Framework Json Example
As we’ve seen in our previous example, Play! is a powerful web mvc framework. Among other stuff, Play has support for rest clients (in its WS package), web sockets, and our subject today: json. In this example, we’ll see how to write a Restful Web Service with Play! Framework with both scala and java languages using java 1.8.0_66, scala 2.11.6 and Play 2.4.3.
- Play! Framework JSON & Scala Example
In this post, we feature a comprehensive Example on Play! Framework JSON & Scala. In my last two posts, we have discussed about Play Framework + Scala + SBT based project basics. Please refer Play! Framework Hello World Example and Play! Framework Path, Query and Route Default Params Example to understand Play + SBT Project structure, Project configurations, SBT configurations etc. This is my third post in Play! Framework Tutorial Series.
- Play! Framework Path, Query and Route Default Params Example
In this post, we are going to discuss about few more Play Framework basics like Path Parameters, Query Parameters, Routing Default Parameters and Routing Fixed Values Parameters in detail with some suitable examples. We will also discuss what is the best approach between Path and Query Parameters to develop REST APIs. We will try to develop separate SBT project for each concept so that we can play or evaluate them very well.