Play framework

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(BrowserID)
(图集)
 
(未显示1个用户的53个中间版本)
第3行: 第3行:
 
[[Image:Play-framework-90x90.gif|right]]
 
[[Image:Play-framework-90x90.gif|right]]
  
Play 是一个 [[Java]] Web框架,很像 [[Ruby]] on [[Rails]], 采用 Apache 2 许可协议。
+
Play 是一个 [[Java]] 和 [[Scala]] Web框架,很像 [[Ruby]] on [[Rails]], 采用 Apache 2 许可协议。
 +
 
 +
==安装==
 +
brew install typesafe-activator
 +
activator new my-first-app play-scala
 +
or activator new my-first-app play-java
 +
cd my-first-app
 +
activator
 +
or activator ui
  
 
==入门==
 
==入门==
第11行: 第19行:
 
  play
 
  play
 
  [help] $ run 8080
 
  [help] $ run 8080
 +
或 start 8080 // crtl-d, 后台运行
 
  http://localhost:8080
 
  http://localhost:8080
 +
 +
[https://github.com/jamesward/six-minute-apps 6 Minute Apps] This is an introduction to building Modern Web Apps with Play Framework, Scala, CoffeeScript, and LESS
 +
 +
更多例子:Play for Scala
 +
git clone https://github.com/playforscala/sample-applications // 可使用 play-2.2 的分支
 +
cd ch02-your-first-play-application/first-sample
 +
sbt
 +
[first-sample] $ eclipse
 +
[first-sample] $ run
 +
http://localhost:9000/
 +
随后,你可以通过 Eclipse 导入刚才的项目,进行代码修改和项目重新构建。
 +
 +
==Spring & CF==
 +
Play 融合 [[Spring]]、[[Cloud Foundry]]
 +
*[http://www.infoq.com/cn/articles/scala_and_spring Scala与Spring:强强联合] Scala和Spring所提供的众多功能使得这一组合成为企业采用Scala的最佳选择。
 +
*[https://github.com/wsargent/play-2.0-spring-module Spring Module for Play 2.0]
 +
*[http://www.playframework.com/documentation/2.1.1/Deploying-CloudFoundry Deploying to Cloud Foundry]
  
 
==Eclipse==
 
==Eclipse==
 +
*[[Scala IDE]]
 +
*[https://github.com/typesafehub/sbteclipse sbteclipse]
 +
 
  cd helloPlay
 
  cd helloPlay
 
  play  
 
  play  
第20行: 第49行:
 
  [info] Sucessfully created Eclipse project files for projects
 
  [info] Sucessfully created Eclipse project files for projects
 
  然后,从 File/Import/General/Existing project 导入刚才的项目
 
  然后,从 File/Import/General/Existing project 导入刚才的项目
 +
 +
在Eclipse中调试Play2 创建的应用
 +
*1. Run->External Tools->External Tools Configuration
 +
*2. 新增一个Program,完成后Run 如下图所示:Run
 +
*3. 选中项目右键Debug As -> Debug Configuration ,新增一个远程调试配置,如下图所示:Debug
 +
注意端口号是9999,play debug run开启的应用,调试端口默认是9999
 +
*4. 打断点,进行调试。如下图所示:Break Point
 +
*5. Enjoyed.
 +
 
更多细节:[http://www.playframework.com/documentation/2.1.1/IDE Setting up your preferred IDE]
 
更多细节:[http://www.playframework.com/documentation/2.1.1/IDE Setting up your preferred IDE]
  
==BrowserID==
+
==安全身份验证==
 +
*[https://github.com/pac4j/play-pac4j play-pac4j] for [[Java]] and [[Scala]]
 +
*[https://github.com/t2v/play2-auth play2-auth: Play2.x Authentication and Authorization module]
 +
*[https://github.com/joscha/play-authenticate PlayAuthenticate] for [[Java]]
 
与 [[BrowserID]] 的整合
 
与 [[BrowserID]] 的整合
 +
*[http://www.playframework.com/modules/browserid BrowserID module]
 +
 +
==数据库==
 +
*[https://github.com/playframework/play-anorm play-anorm] [https://github.com/Hawstein/play-for-scala-developers/blob/master/ch08/ScalaAnorm.md Anorm, 简单的SQL数据访问]
 +
*[https://github.com/playframework/play-slick Play Slick] [https://github.com/typesafehub/activator-hello-slick A Slick template for Typesafe Activator]
 +
*[https://brettwooldridge.github.io/HikariCP/ HikariCP]
  
 
==Modules==
 
==Modules==
现在的 [http://www.playframework.com/documentation/2.1.1/Modules Modules],未来向marketplace方向发展。
+
现在的 [https://www.playframework.com/documentation/2.5.x/ModuleDirectory Modules],未来向marketplace方向发展 :)
 +
*[http://www.playframework.com/modules Modules repository]
 +
*[http://www.playframework.com/modules/redis Redis module]
 +
*[https://github.com/play2war/play2-war-plugin play2-war-plugin] WAR Plugin for Play framework 2.x
 +
*[https://github.com/Kaliber/play-s3 play-s3] [[Amazon S3]] module for play 2.5
 +
*[https://github.com/adrianhurt/play-bootstrap play-bootstrap]
 +
 
 +
==sbt==
 +
*[[Activator]]
 +
*[[sbt]] 是一个 [[Scala]] 和 [[Java]] 项目构建工具。
 +
 
 +
==REPL==
 +
*[https://www.playframework.com/documentation/2.5.x/PlayConsole Using the Play console]
 +
在play项目目录下,执行 activator
 +
$ help
 +
$ console
 +
scala> views.html.index("hello")
 +
 
 +
==HTTP & REST & Akka==
 +
*[https://www.playframework.com/documentation/2.5.x/ScalaAkka Scala Integrating with Akka] [https://www.playframework.com/documentation/2.5.x/JavaAkka Java Integrating with Akka]
 +
*[[Netty]]
 +
*[https://www.playframework.com/documentation/2.5.x/AkkaHttpServer Akka HTTP]
 +
*[[spray]]
 +
*[https://github.com/typesafehub/play2-mini Play2 Mini Project] provides REST API on top of Play2
 +
*[https://github.com/swagger-api/swagger-play Swagger Play Integration]
 +
 
 +
==用户==
 +
*[http://docs.huihoo.com/play/play-case-study-linkedin-v1.2.pdf The Play Framework at LinkedIn]
 +
*[https://tech.coursera.org/blog/2014/02/18/why-we-love-scala-at-coursera/ Why we love Scala at Coursera]
 +
*[http://typesafe.com/company/casestudies 更多用户案例]
 +
 
 +
==课程==
 +
*[https://www.coursera.org/course/progfun Functional Programming, 函数式程序设计原理]
 +
*[https://www.coursera.org/course/reactive Reactive Programming, 响应式程序设计原理]
  
 
==图集==
 
==图集==
 
<gallery>
 
<gallery>
 +
image:play-framework-stack.png|Play框架堆栈
 +
image:play-framework-components.png|Play框架组件
 +
image:play-model-application.png|Play模型应用
 +
image:single-page-play-application.png|单页Play应用
 +
image:play-persistence-layer.png|Play持久层
 
image:play-standard-application-layout.png|标准应用布局
 
image:play-standard-application-layout.png|标准应用布局
 
image:play-http-request-diagrams-path.png|HTTP请求
 
image:play-http-request-diagrams-path.png|HTTP请求
 +
image:play-on-eclipse-run.jpg|Run
 +
image:play-on-eclipse-remote-debug.png|Debug
 +
image:play-on-eclipse-breakpoint.png|Breakpoint
 +
image:typesafe-activator-play-2.4.2.png|Play 2.4.2
 
</gallery>
 
</gallery>
  
 
==链接==
 
==链接==
 
*[http://www.playframework.org/ Play官网]
 
*[http://www.playframework.org/ Play官网]
 +
*[https://github.com/playframework Play Framework @ GitHub]
 
*[http://docs.huihoo.com/play Play开放文档]
 
*[http://docs.huihoo.com/play Play开放文档]
 +
*[https://github.com/playforscala/sample-applications Play for Scala source code]
 
*[http://docs.huihoo.com/javadoc/play Javadoc]
 
*[http://docs.huihoo.com/javadoc/play Javadoc]
 
*[http://download.huihoo.com/play 下载]
 
*[http://download.huihoo.com/play 下载]
  
 
[[category:framework]]
 
[[category:framework]]
 +
[[category:marketplace]]
 
[[category:MVC]]
 
[[category:MVC]]
 
[[category:java]]
 
[[category:java]]
 
[[category:scala]]
 
[[category:scala]]
 +
[[category:huihoo]]

2021年7月28日 (三) 08:33的最后版本

Wikipedia-35x35.png 您可以在Wikipedia上了解到此条目的英文信息 Play framework Thanks, Wikipedia.
Play-framework-90x90.gif

Play 是一个 JavaScala Web框架,很像 Ruby on Rails, 采用 Apache 2 许可协议。

目录

[编辑] 安装

brew install typesafe-activator
activator new my-first-app play-scala
or activator new my-first-app play-java
cd my-first-app
activator
or activator ui

[编辑] 入门

play new helloPlay
选 1 Scala应用 或 2 Java应用
cd helloPlay
play
[help] $ run 8080
或 start 8080 // crtl-d, 后台运行
http://localhost:8080

6 Minute Apps This is an introduction to building Modern Web Apps with Play Framework, Scala, CoffeeScript, and LESS

更多例子:Play for Scala

git clone https://github.com/playforscala/sample-applications // 可使用 play-2.2 的分支

cd ch02-your-first-play-application/first-sample

sbt
[first-sample] $ eclipse
[first-sample] $ run 
http://localhost:9000/

随后,你可以通过 Eclipse 导入刚才的项目,进行代码修改和项目重新构建。

[编辑] Spring & CF

Play 融合 SpringCloud Foundry

[编辑] Eclipse

cd helloPlay
play 
[help] $ eclipse with-source=true
...
[info] Sucessfully created Eclipse project files for projects
然后,从 File/Import/General/Existing project 导入刚才的项目

在Eclipse中调试Play2 创建的应用

  • 1. Run->External Tools->External Tools Configuration
  • 2. 新增一个Program,完成后Run 如下图所示:Run
  • 3. 选中项目右键Debug As -> Debug Configuration ,新增一个远程调试配置,如下图所示:Debug

注意端口号是9999,play debug run开启的应用,调试端口默认是9999

  • 4. 打断点,进行调试。如下图所示:Break Point
  • 5. Enjoyed.

更多细节:Setting up your preferred IDE

[编辑] 安全身份验证

BrowserID 的整合

[编辑] 数据库

[编辑] Modules

现在的 Modules,未来向marketplace方向发展 :)

[编辑] sbt

[编辑] REPL

在play项目目录下,执行 activator

$ help
$ console
scala> views.html.index("hello")

[编辑] HTTP & REST & Akka

[编辑] 用户

[编辑] 课程

[编辑] 图集

[编辑] 链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱