Book Image

Mastering play framework for scala

By : Shiti Saxena
Book Image

Mastering play framework for scala

By: Shiti Saxena

Overview of this book

Table of Contents (21 chapters)
Mastering Play Framework for Scala
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
Getting Started with Play
Index

Experimenting in a Scala console


A Scala console is very handy when you're working on a Scala project. The same console is available in our Play application's console as well. All that we need to do to get the Scala console is execute the console command in our application console:

[app]$ console
[info] Compiling 3 Scala sources to /home/app/target/scala-2.10/classes...
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_60).
Type in expressions to have them evaluated.
Type :help for more information.

scala>

However, we can only call methods from models or utils. If classes or objects within these packages utilize Play.application.configuration or attempt to fetch data from the DB or some other Play utils, we will not be able to instantiate them. This is because most of the Play components require access to an instance of the currently running Play application. Importing play.api.Play.current makes this possible...