how to play at work - a play framework tutorial
DESCRIPTION
Below are the minimum system specifications to develop an application in Play Framework for Windows, Mac and Linux.TRANSCRIPT
PowerPoint Presentation
A Play Framework Tutorial
Assist-Software Romania- Marius CarpWhat is Play Framework
An open-source modern web framework Based on a lightweight, stateless, web-friendly architecture. Built on Akka, Play provides predictable and minimal resource consumptionDeveloper friendlyHas great support for Eclipse and Intellij IDEA.Provides RESTful by defaultHas a built-in JSON module and extensive NoSQL & Big Data Support. There are libraries for everything - most of which can be used in Play.
System Requirements
InstallJDK 1.6 or later.InstallScala (general-purpose language designed to support clear, concise and type-safe programming). Optional, but good to have, you may also useJava.InstallSBTis an open source build tool for Scala and Java projects, similar to Java's Maven or Ant. InstallPlay Frameworkthrough a tool calledTypesafe Activator.InstallPostgreSQL.InstallpgAdminis a comprehensive PostgreSQL database design and management system.
Game Play Tutorial
Let's create a new vanilla Play Scala application and name itscala-game. Here isthe command you need to run it in command-line:
To start your game from command-line run from your project root folder:
or (recommanded)
To view your workgo to:http://localhost:9000/
Game Configuration Tutorial
To add more experience to yourPlayskills add the following dependencies to yourbuild.sbtfile:
Slick- a modern database query and access library for Scala. -It allows you to work with stored data and gives you full control
PostgreSQL JDBCis necessaryto connect to PostgreSQL database
Game Configuration Tutorial
Then, create a database and add its credentials toapplication.configfile. Add a package nameddaoto your app folderDefine database tables and set it in configuration Uncommentevolution pluginand set it enabled Play Framework's Evolutionswill create tables and relations between them (primary keys, indexes, sequences etc...) for you.
Game Configuration Tutorial
We have to specify to whichdatabase to connect creating a trait namedPostgresSupportand define an implicit database
Loading Textures in Play Framework
Create a package models and in it a case class named Player
Play tracks your database evolutions using several evolution scripts located in the db/evolutions directory.
The first script is named1.sql.
We just need to map the models to tabels. PostgreSQLwill generate aPrimaryKeyfor the player usingAutoInc:Loading Textures in Play Framework
A GET HTTP request will be made to this route"/ when a user first time accesses our application . The entire list of routes can be found in theconf/routesfile Each route consists of an HTTP method and URI pattern, both associated with a call to an Action generator.An Action is basically a request => result function that handles a request and generates a result to be sent to the client.AControlleris nothing more than a singleton object that generatesActionvalues.
Play Framework Game modes
You can chose to Play in two ways:Single playerusingPlay Scala templateMulti playerusing one of the following JavaScript frameworks:AngularJS,BackboneJS,EmberJS,ExtJS,DustJS.Adding a new player and get players list usingSlick.players list (playersis the mapped table)
add new player
Single Player APlay Scala template
Is a simple text file, that contains small blocks of Scala code.Can generate any text-based format, such as HTML, XML or CSV. Allow web designers to easily work with the templates. Templates are compiled as standard Scala functions.If you create aviews/Application/index.scala.htmltemplate file, it will generate aviews.html.Application.indexfunction.
Single Player APlay Scala template
Inindex.scala.html we havethe player listPlay Framework will render the page server-side.
Adding players to the game is as simple as that: submit a form usingPOSTto this route/player/single
Multi Player
You will have two separated applications in one project:API Backend(presistent data) Frontend side(making AJAX calls to the server)- in public folder.To test your calls usePostman.Make a GET call to/player/multiThis willexecutecontrollers.Application.findAlland it will return a list of players inJSONformat.
Multi Player
Example:
To add a player usePOSTmethod to this route/player/multiwith the followingJSONbody:{ "name": "Newbie", "level": 1}
Game Features
Amazon S3 module (Scala) - allows you to list, get, add and remove items from a S3 bucket.Authentication and Authorization module (Scala) - offers Authentication and Authorization features to Play2.x applications.Deadbolt 2 Plugin -powerful authorisation mechanism for defining access rights to certain controller methods Dust Plugin provides support for the dust client side template language (DustJS).Memcached Plugin - provides a memcached based cache implementation.MongoDB Salat, Casbah Plugin (Scala) - provides managed MongoDB access and object mapping using Salat and CasbahRedis Plugin (Java and Scala) - provides a redis based cache implementationSecureSocial (Java and Scala) - an authentication module supporting OAuth, OAuth2, OpenID, Username/Password and custom authentication schemes.
Most popular Players
LinkedInThe GuardianTwitterFoursquareCourseraKloutWalmart
More details here: http://assist-software.net/blog/how-play-work-play-framework-tutorial