play.api
Contains the public API for Scala developers.
==== Read configuration ====
val poolSize = configuration.getInt("engine.pool.size")
==== Use the logger ====
Logger.info("Hello!")
==== Define a Plugin ====
class MyPlugin(app: Application) extends Plugin
==== Create adhoc applications (for testing) ====
val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
Attributes
Members list
Packages
Contains data manipulation helpers (typically HTTP form handling)
Contains data manipulation helpers (typically HTTP form handling)
import play.api.data._
import play.api.data.Forms._
val taskForm = Form(
tuple(
"name" -> text(minLength = 3),
"dueDate" -> date("yyyy-MM-dd"),
"done" -> boolean
)
)
Attributes
Contains standard HTTP constants. For example:
Contains standard HTTP constants. For example:
val text = ContentTypes.TEXT
val ok = Status.OK
val accept = HeaderNames.ACCEPT
Attributes
Contains the internationalisation API.
Contains the internationalisation API.
For example, translating a message:
val msgString = Messages("items.found", items.size)
Attributes
Play's runtime dependency injection abstraction.
Play's runtime dependency injection abstraction.
Play's runtime dependency injection support is built on JSR-330, which provides a specification for declaring how dependencies get wired to components. JSR-330 however does not address how components are provided to or located by a DI container. Play's API seeks to address this in a DI container agnostic way.
The reason for providing this abstraction is so that Play, the modules it provides, and third party modules can all express their bindings in a way that is not specific to any one DI container.
Components are bound in the DI container. Each binding is identified by a BindingKey, which is typically an interface that the component implements, and may be optionally qualified by a JSR-330 qualifier annotation. A binding key is bound to a BindingTarget, which describes how the implementation of the interface that the binding key represents is constructed or provided. Bindings may also be scoped using JSR-330 scope annotations.
Bindings are provided by instances of Module.
Out of the box, Play provides an implementation of this abstraction using Guice.
Attributes
- See also
-
The Module class for information on how to provide bindings.
Contains various APIs that are useful while developing web applications.
Contains various APIs that are useful while developing web applications.
Attributes
Contains the Controller/Action/Result API to handle HTTP requests.
Contains the Controller/Action/Result API to handle HTTP requests.
For example, a typical controller:
class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
def index = Action {
Ok("It works!")
}
}
Attributes
Type members
Classlikes
A Play application.
A Play application.
Application creation is handled by the framework engine.
If you need to create an ad-hoc application, for example in case of unit testing, you can easily achieve this using:
val application = new DefaultApplication(new File("."), this.getClass.getClassloader, None, Play.Mode.Dev)
This will create an application using the current classloader.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class DefaultApplication
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Application.type
Loads an application. This is responsible for instantiating an application given a context.
Loads an application. This is responsible for instantiating an application given a context.
Application loaders are expected to instantiate all parts of an application, wiring everything together. They may be manually implemented, if compile time wiring is preferred, or core/third party implementations may be used, for example that provide a runtime dependency injection framework.
During dev mode, an ApplicationLoader will be instantiated once, and called once, each time the application is reloaded. In prod mode, the ApplicationLoader will be instantiated and called once when the application is started.
Out of the box Play provides a Guice module that defines a Java and Scala default implementation based on Guice, as well as various helpers like GuiceApplicationBuilder. This can be used simply by adding the "PlayImport.guice" dependency in build.sbt.
A custom application loader can be configured using the play.application.loader configuration property. Implementations must define a no-arg constructor.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ApplicationLoader.type
Helper to provide the Play built in components.
Helper to provide the Play built in components.
Attributes
- Supertypes
-
trait PekkoTypedComponentstrait PekkoComponentstrait I18nComponentsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
This helper class provides all the built-in component dependencies by trading them for a single dependency
This helper class provides all the built-in component dependencies by trading them for a single dependency
- the application loader context.
Attributes
- Supertypes
-
trait BuiltInComponentstrait PekkoTypedComponentstrait PekkoComponentstrait I18nComponentsclass Objecttrait Matchableclass AnyShow all
This helper trait provides all the built-in component dependencies by trading them for a single dependency
This helper trait provides all the built-in component dependencies by trading them for a single dependency
- the application loader context.
Attributes
- Supertypes
-
trait BuiltInComponentstrait PekkoTypedComponentstrait PekkoComponentstrait I18nComponentsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
Attributes
- Supertypes
A default marker context. This is used by MarkerContext.apply, but can also be used to provide explicit typing for markers. For example, to define a SecurityContext marker, you can define a case object extending DefaultMarkerContext:
A default marker context. This is used by MarkerContext.apply, but can also be used to provide explicit typing for markers. For example, to define a SecurityContext marker, you can define a case object extending DefaultMarkerContext:
case object SecurityMarkerContext extends DefaultMarkerContext(MarkerFactory.getMarker("SECURITY"))
Value parameters
- someMarker
-
a marker used in the
markermethod.
Attributes
- Supertypes
- Known subtypes
-
object SecurityMarkerContext
A Play logger.
A Play logger.
Value parameters
- logger
-
the underlying SL4FJ logger
Attributes
- Companion
- object
- Supertypes
High-level API for logging operations.
Runs through underlying logger configuration.
Runs through underlying logger configuration.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
LoggerConfigurator.type
Typical logger interface.
Typical logger interface.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class Logger
A trait that can mixed into a class or trait to add a logger named based on the class name.
A trait that can mixed into a class or trait to add a logger named based on the class name.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object MarkerContext
A MarkerContext trait, to provide easy access to org.slf4j.Marker in Logger API. This is usually accessed with a marker through an implicit conversion from a Marker.
A MarkerContext trait, to provide easy access to org.slf4j.Marker in Logger API. This is usually accessed with a marker through an implicit conversion from a Marker.
implicit val markerContext: MarkerContext = org.slf4j.MarkerFactory.getMarker("EXAMPLEMARKER")
log.error("This message will be logged with the EXAMPLEMARKER marker")
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class DefaultMarkerContextobject SecurityMarkerContext
Attributes
- Companion
- trait
- Supertypes
- Self type
-
MarkerContext.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
MarkerContexts.type
A component to mix in when no default filters should be mixed in to BuiltInComponents.
A component to mix in when no default filters should be mixed in to BuiltInComponents.
Attributes
- See also
- Supertypes
-
class Objecttrait Matchableclass Any
Represents an Option[DevContext] so that it can be used for dependency injection. We can't easily use a plain Option[DevContext] since Java erases the type parameter of that type.
Represents an Option[DevContext] so that it can be used for dependency injection. We can't easily use a plain Option[DevContext] since Java erases the type parameter of that type.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Represents an Option[SourceMapper] so that it can be used for dependency injection. We can't easily use a plain Option[SourceMapper] since Java erases the type parameter of that type.
Represents an Option[SourceMapper] so that it can be used for dependency injection. We can't easily use a plain Option[SourceMapper] since Java erases the type parameter of that type.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
High-level API to access Play global features.
High-level API to access Play global features.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Play.type
Generic exception for unexpected error cases.
Generic exception for unexpected error cases.
Attributes
- Supertypes
-
trait Producttrait Equalsclass PlayExceptionclass UsefulExceptionclass RuntimeExceptionclass Exceptionclass Throwabletrait Serializableclass Objecttrait Matchableclass AnyShow all