SlideShare a Scribd company logo
1 of 16
Download to read offline
A Play Framework Tutorial
Assist-Software Romania- Marius Carp
What 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 consumption
• Developer friendly
• Has great support for Eclipse and Intellij IDEA.
• Provides RESTful by default
• Has 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
• Install JDK 1.6 or later.
• Install Scala (general-purpose language designed to support clear, concise and
type-safe programming). Optional, but good to have, you may also use Java.
• Install SBT is an open source build tool for Scala and Java projects, similar to
Java's Maven or Ant.
• Install Play Framework through a tool called Typesafe Activator.
• Install PostgreSQL.
• Install pgAdmin is a comprehensive PostgreSQL database design and
management system.
Game Play Tutorial
• Let's create a new vanilla Play Scala application and name it scala-game. Here
is the 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 work go to: http://localhost:9000/
Game Configuration Tutorial
• To add more experience to your Play skills add the following dependencies to
your build.sbt file:
• Slick - a modern database query and access library for Scala.
-It allows you to work with stored data and gives you full control
• PostgreSQL JDBC is necessary to connect to PostgreSQL database
Game Configuration Tutorial
• Then, create a database and add its credentials to application.config file.
• Add a package named dao to your app folder
• Define database tables and set it in configuration
• Uncomment evolution plugin and set it enabled
• Play Framework's Evolutions will create tables and relations between them
(primary keys, indexes, sequences etc...) for you.
Game Configuration Tutorial
• We have to specify to which database to connect creating a trait
named PostgresSupport and 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 named 1.sql.
• We just need to map the models to tabels.
• PostgreSQL will generate a PrimaryKey for the player
using AutoInc:
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 the conf/routes file
• 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.
• A Controller is nothing more than a singleton object that generates Action values.
Play Framework Game modes
• You can chose to Play in two ways:
• Single player using Play Scala template
• Multi player using one of the following JavaScript frameworks: AngularJS, BackboneJS, EmberJS, ExtJS, DustJS .
• Adding a new player and get players list using Slick.
• players list (players is the mapped table)
• add new player
Single Player
A Play 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 a views/Application/index.scala.html template file,
it will generate a views.html.Application.indexfunction.
Single Player
A Play Scala template
• In index.scala.html we have the player list
• Play Framework will render the page server-side.
• Adding players to the game is as simple as that: submit a form
using POST to 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 use Postman.
• Make a GET call to /player/multi
• This will execute controllers.Application.findAll and it will return a list
of players in JSON format.
Multi Player
• Example:
• To add a player use POST method to this route /player/multi with the
following JSON body:
{
"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 Casbah
• Redis Plugin (Java and Scala) - provides a redis based cache implementation
• SecureSocial (Java and Scala) - an authentication module supporting OAuth, OAuth2, OpenID, Username/Password and
custom authentication schemes.
Most popular Players
• LinkedIn
• The Guardian
• Twitter
• Foursquare
• Coursera
• Klout
• Walmart
More details here: http://assist-software.net/blog/how-play-work-play-framework-tutorial

More Related Content

What's hot

okuyama_20101101_nosqlafternoon
okuyama_20101101_nosqlafternoonokuyama_20101101_nosqlafternoon
okuyama_20101101_nosqlafternoonTakahiro Iwase
 
OpenStack Keystone with LDAP
OpenStack Keystone with LDAPOpenStack Keystone with LDAP
OpenStack Keystone with LDAPJesse Pretorius
 
OGDC2012 Lua In Game_Mr. Van, Nguyen Ngoc
OGDC2012 Lua In Game_Mr. Van, Nguyen NgocOGDC2012 Lua In Game_Mr. Van, Nguyen Ngoc
OGDC2012 Lua In Game_Mr. Van, Nguyen NgocBuff Nguyen
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Dylan Butler
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...Sencha
 
How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)Ankit Kaneri
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell scriptDavid Cobb
 
Monitor Micro-service with MicroProfile metrics
Monitor Micro-service with MicroProfile metricsMonitor Micro-service with MicroProfile metrics
Monitor Micro-service with MicroProfile metricsRudy De Busscher
 
All your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginAll your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginSamuel Le Berrigaud
 
Windows Azure Blob Storage
Windows Azure Blob StorageWindows Azure Blob Storage
Windows Azure Blob Storageylew15
 
Backup and Restore SQL Server Databases in Microsoft Azure
Backup and Restore SQL Server Databases in Microsoft AzureBackup and Restore SQL Server Databases in Microsoft Azure
Backup and Restore SQL Server Databases in Microsoft AzureDatavail
 
Running on Elastic Beanstalk
Running on Elastic BeanstalkRunning on Elastic Beanstalk
Running on Elastic BeanstalkAlex Verdyan
 

What's hot (20)

okuyama_20101101_nosqlafternoon
okuyama_20101101_nosqlafternoonokuyama_20101101_nosqlafternoon
okuyama_20101101_nosqlafternoon
 
OpenStack Keystone with LDAP
OpenStack Keystone with LDAPOpenStack Keystone with LDAP
OpenStack Keystone with LDAP
 
OGDC2012 Lua In Game_Mr. Van, Nguyen Ngoc
OGDC2012 Lua In Game_Mr. Van, Nguyen NgocOGDC2012 Lua In Game_Mr. Van, Nguyen Ngoc
OGDC2012 Lua In Game_Mr. Van, Nguyen Ngoc
 
Presentation
PresentationPresentation
Presentation
 
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
Transitioning From SQL Server to MySQL - Presentation from Percona Live 2016
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)How to run appache spark on windows(in sbt console)
How to run appache spark on windows(in sbt console)
 
SQLite 3
SQLite 3SQLite 3
SQLite 3
 
Sqlite
SqliteSqlite
Sqlite
 
My first powershell script
My first powershell scriptMy first powershell script
My first powershell script
 
Monitor Micro-service with MicroProfile metrics
Monitor Micro-service with MicroProfile metricsMonitor Micro-service with MicroProfile metrics
Monitor Micro-service with MicroProfile metrics
 
All your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects PluginAll your data belong to us - The Active Objects Plugin
All your data belong to us - The Active Objects Plugin
 
eCAP Developer Walkthru
eCAP Developer WalkthrueCAP Developer Walkthru
eCAP Developer Walkthru
 
Getting Started with SQLite
Getting Started with SQLiteGetting Started with SQLite
Getting Started with SQLite
 
Introduction to AJAX
Introduction to AJAXIntroduction to AJAX
Introduction to AJAX
 
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir DžaferovićJavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
JavaCro'14 - Continuous deployment tool – Aleksandar Dostić and Emir Džaferović
 
Windows Azure Blob Storage
Windows Azure Blob StorageWindows Azure Blob Storage
Windows Azure Blob Storage
 
Backup and Restore SQL Server Databases in Microsoft Azure
Backup and Restore SQL Server Databases in Microsoft AzureBackup and Restore SQL Server Databases in Microsoft Azure
Backup and Restore SQL Server Databases in Microsoft Azure
 
ppt
pptppt
ppt
 
Running on Elastic Beanstalk
Running on Elastic BeanstalkRunning on Elastic Beanstalk
Running on Elastic Beanstalk
 

Similar to How to Play at Work - A Play Framework Tutorial

XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the BasicsUlrich Krause
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web DevelopersKyle Cearley
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUlrich Krause
 
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft Engineer
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft EngineerPLSSUG - Troubleshoot SQL Server performance problems like a Microsoft Engineer
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft EngineerMarek Maśko
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPagesUlrich Krause
 
Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.pptYoung Alista
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsTeamstudio
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScriptkoppenolski
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSpeedment, Inc.
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearchErhwen Kuo
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopersBryan Cafferky
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disquszeeg
 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansPeter Clapham
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)Mathew Beane
 

Similar to How to Play at Work - A Play Framework Tutorial (20)

XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics[DanNotes] XPages - Beyound the Basics
[DanNotes] XPages - Beyound the Basics
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft Engineer
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft EngineerPLSSUG - Troubleshoot SQL Server performance problems like a Microsoft Engineer
PLSSUG - Troubleshoot SQL Server performance problems like a Microsoft Engineer
 
Extension Library - Viagra for XPages
Extension Library - Viagra for XPagesExtension Library - Viagra for XPages
Extension Library - Viagra for XPages
 
Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.ppt
 
Access Data from XPages with the Relational Controls
Access Data from XPages with the Relational ControlsAccess Data from XPages with the Relational Controls
Access Data from XPages with the Relational Controls
 
Intro JavaScript
Intro JavaScriptIntro JavaScript
Intro JavaScript
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
06 integrate elasticsearch
06 integrate elasticsearch06 integrate elasticsearch
06 integrate elasticsearch
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
DjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
 
Sanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticiansSanger, upcoming Openstack for Bio-informaticians
Sanger, upcoming Openstack for Bio-informaticians
 
Flexible compute
Flexible computeFlexible compute
Flexible compute
 
Hibernate java and_oracle
Hibernate java and_oracleHibernate java and_oracle
Hibernate java and_oracle
 
ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)ELK Ruminating on Logs (Zendcon 2016)
ELK Ruminating on Logs (Zendcon 2016)
 

More from AssistSoftware

L2L Entrepreneurship 2nd Newsletter
L2L Entrepreneurship 2nd NewsletterL2L Entrepreneurship 2nd Newsletter
L2L Entrepreneurship 2nd NewsletterAssistSoftware
 
L2L Entrepreneurship Newsletter
L2L Entrepreneurship NewsletterL2L Entrepreneurship Newsletter
L2L Entrepreneurship NewsletterAssistSoftware
 
Bonafide comunicat de presa
Bonafide   comunicat de presaBonafide   comunicat de presa
Bonafide comunicat de presaAssistSoftware
 
ASSIST Software Brochure
ASSIST Software BrochureASSIST Software Brochure
ASSIST Software BrochureAssistSoftware
 
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...AssistSoftware
 
Assist software awesome scala
Assist software   awesome scalaAssist software   awesome scala
Assist software awesome scalaAssistSoftware
 

More from AssistSoftware (6)

L2L Entrepreneurship 2nd Newsletter
L2L Entrepreneurship 2nd NewsletterL2L Entrepreneurship 2nd Newsletter
L2L Entrepreneurship 2nd Newsletter
 
L2L Entrepreneurship Newsletter
L2L Entrepreneurship NewsletterL2L Entrepreneurship Newsletter
L2L Entrepreneurship Newsletter
 
Bonafide comunicat de presa
Bonafide   comunicat de presaBonafide   comunicat de presa
Bonafide comunicat de presa
 
ASSIST Software Brochure
ASSIST Software BrochureASSIST Software Brochure
ASSIST Software Brochure
 
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...
ASSIST Software - Software Development & Outsourcing Company Romania, Eastern...
 
Assist software awesome scala
Assist software   awesome scalaAssist software   awesome scala
Assist software awesome scala
 

Recently uploaded

Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotEdgard Alejos
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 

Recently uploaded (20)

Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform Copilot
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 

How to Play at Work - A Play Framework Tutorial

  • 1. A Play Framework Tutorial Assist-Software Romania- Marius Carp
  • 2. What 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 consumption • Developer friendly • Has great support for Eclipse and Intellij IDEA. • Provides RESTful by default • Has a built-in JSON module and extensive NoSQL & Big Data Support. • There are libraries for everything - most of which can be used in Play.
  • 3. System Requirements • Install JDK 1.6 or later. • Install Scala (general-purpose language designed to support clear, concise and type-safe programming). Optional, but good to have, you may also use Java. • Install SBT is an open source build tool for Scala and Java projects, similar to Java's Maven or Ant. • Install Play Framework through a tool called Typesafe Activator. • Install PostgreSQL. • Install pgAdmin is a comprehensive PostgreSQL database design and management system.
  • 4. Game Play Tutorial • Let's create a new vanilla Play Scala application and name it scala-game. Here is the 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 work go to: http://localhost:9000/
  • 5. Game Configuration Tutorial • To add more experience to your Play skills add the following dependencies to your build.sbt file: • Slick - a modern database query and access library for Scala. -It allows you to work with stored data and gives you full control • PostgreSQL JDBC is necessary to connect to PostgreSQL database
  • 6. Game Configuration Tutorial • Then, create a database and add its credentials to application.config file. • Add a package named dao to your app folder • Define database tables and set it in configuration • Uncomment evolution plugin and set it enabled • Play Framework's Evolutions will create tables and relations between them (primary keys, indexes, sequences etc...) for you.
  • 7. Game Configuration Tutorial • We have to specify to which database to connect creating a trait named PostgresSupport and define an implicit database
  • 8. 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 named 1.sql. • We just need to map the models to tabels. • PostgreSQL will generate a PrimaryKey for the player using AutoInc:
  • 9. 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 the conf/routes file • 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. • A Controller is nothing more than a singleton object that generates Action values.
  • 10. Play Framework Game modes • You can chose to Play in two ways: • Single player using Play Scala template • Multi player using one of the following JavaScript frameworks: AngularJS, BackboneJS, EmberJS, ExtJS, DustJS . • Adding a new player and get players list using Slick. • players list (players is the mapped table) • add new player
  • 11. Single Player A Play 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 a views/Application/index.scala.html template file, it will generate a views.html.Application.indexfunction.
  • 12. Single Player A Play Scala template • In index.scala.html we have the player list • Play Framework will render the page server-side. • Adding players to the game is as simple as that: submit a form using POST to this route /player/single
  • 13. 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 use Postman. • Make a GET call to /player/multi • This will execute controllers.Application.findAll and it will return a list of players in JSON format.
  • 14. Multi Player • Example: • To add a player use POST method to this route /player/multi with the following JSON body: { "name": "Newbie", "level": 1 }
  • 15. 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 Casbah • Redis Plugin (Java and Scala) - provides a redis based cache implementation • SecureSocial (Java and Scala) - an authentication module supporting OAuth, OAuth2, OpenID, Username/Password and custom authentication schemes.
  • 16. Most popular Players • LinkedIn • The Guardian • Twitter • Foursquare • Coursera • Klout • Walmart More details here: http://assist-software.net/blog/how-play-work-play-framework-tutorial