Your new application is ready.

Welcome to Play

Congratulations, you’ve just created a new Play application. This page will help you with the next few steps.

You’re using Play 2.6.12

Why do you see this page?

The conf/routes file defines a route that tells Play to invoke the HomeController.index action whenever a browser requests the / URI using the GET method:

# Home page
GET     /               controllers.HomeController.index

Play has invoked the controllers.HomeController.index method to obtain the Action to execute:

def index = Action {
  Ok(views.html.index("Your new application is ready."))
}

An action is a function that handles the incoming HTTP request, and returns the HTTP result to send back to the web client. Here we send a 200 OK response, using a template to fill its content.

The template is defined in the app/views/index.scala.html file and compiled as a Scala function.

@(message: String)

@main("Welcome to Play") {

    @welcome(message, style = "scala")

}

The first line of the template defines the function signature. Here it just takes a single String parameter. This template then calls another function defined in app/views/main.scala.html, which displays the HTML layout, and another function that displays this welcome message. You can freely add any HTML fragment mixed with Scala code in this file.

You can read more about Twirl, the template language used by Play, and how Play handles actions.

Async Controller

Now that you've seen how Play renders a page, take a look at AsyncController.scala, which shows how to do asynchronous programming when handling a request. The code is almost exactly the same as HomeController.scala, but instead of returning Result, the action returns Future[String] to Play. When the execution completes, Play can use a thread to render the result without blocking the thread in the mean time.

Click here for the AsyncController action!

You can read more about asynchronous actions in the documentation.

Count Controller

Both the HomeController and AsyncController are very simple, and typically controllers present the results of the interaction of several services. As an example, see the CountController, which shows how to inject a component into a controller and use the component when handling requests. The count controller increments every time you click on it, so keep clicking to see the numbers go up.

Click here for the CountController action!

You can read more about dependency injection in the documentation.

Need more info on the console?

For more information on the various commands you can run on Play, i.e. running tests and packaging applications for production, see Using the Play console.

Need to set up an IDE?

You can start hacking your application right now using any text editor. Any changes will be automatically reloaded at each page refresh, including modifications made to Scala source files.

If you want to set-up your application in IntelliJ IDEA or any other Java IDE, check the Setting up your preferred IDE page.

Need more documentation?

Play documentation is available at https://www.playframework.com/documentation.

Play comes with lots of example templates showcasing various bits of Play functionality at https://www.playframework.com/download#examples.

Need more help?

Play questions are asked and answered on Stackoverflow using the "playframework" tag: https://stackoverflow.com/questions/tagged/playframework

The Discuss Play Forum is where Play users come to seek help, announce projects, and discuss issues and new features.

Gitter is a real time chat channel, like IRC. The playframework/playframework channel is used by Play users to discuss the ins and outs of writing great Play applications.