Book Image

Play Framework Cookbook

By : Alexander Reelsen
Book Image

Play Framework Cookbook

By: Alexander Reelsen

Overview of this book

<p>The Play framework is the new kid on the block of Java frameworks. By breaking with existing standards the play framework tries not to abstract away from HTTP as most web frameworks do, but tightly integrates with it. This means quite a shift for Java programmers. Understanding these concepts behind the play framework and its impact on web development with Java are crucial for fast development of applications.<br /><br />The Play Framework Cookbook starts where the beginner documentation ends. It shows you how to utilize advanced features of the Play framework &ndash; piece by piece and completely outlined with working applications!<br /><br />The reader will be taken through all layers of the Play Framework and provided with in-depth knowledge from as many examples and applications as possible. Leveraging the most from the Play framework means to think simple again in a java environment. Implement your own renderers, integrate tightly with HTTP, use existing code, improve site performance with caching and integrate with other web services and interfaces. Learn about non-functional issues like modularity or integration into production and testing environments. In order to provide the best learning experience during reading Play Framework Cookbook, almost every example is provided with source code, so you can start immediately to integrate recipes into your own play applications.</p>
Table of Contents (16 chapters)
Play Framework Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Further Information About the Play Framework
Index

Downloading and installing the Play framework


This recipe will help you to install the Play framework as quickly and unobtrusively as possible in your current system.

Getting ready

All you need is a browser and some basic knowledge about unzipping and copying files in your operating system. Also be aware that you can install Play on Microsoft Windows, Linux as well as Mac OS X or even BSD.

How to do it...

Open up a browser and go to http://www.playframework.org/download and download the most up-to-date stable version http://download.playframework.org/releases/play-1.2.zip (at the time of writing this recpe play 1.2 was the latest stable version).

After downloading it, unzip it, either with a GUI tool or via command line zip:

unzip play-1.1.zip

If you are using Linux or MacOS you might want to put the unzipped directory in /usr/local/ in order to make Play available to all the users on your system; however, this is optional and requires the root access on the particular system:

mv play-1.1 /usr/local/

As a last step adding the Play binary inside the play-1.1 directory to the PATH environment variale is encouraged. This is easily possible with a symlink:

ln -s /usr/local/play-1.1/play /usr/local/bin/play

If you enter play on your commandline, you should get an ASCII art output along with some help and, most importantly, the version of Play you just called. If you do not want to create a symlink, you can also copy the Play binary to a path, which is already included in the PATH variable. In the preceding example you could have copied it to /usr/local/bin.

How it works...

As just mentioned, Play would also work by just unzipping the Play framework archive and always using the absolute path of your installation. However, as this is not very convenient, you should put your installation at the defined location. This also makes it quite easy for you to replace old Play framework versions against newer ones, without having to change anything else than the created symlink.

If you are on a Linux system and you do not see the ASCII art output as mentioned some time back, it might very well be possible that you already have a Play binary on your system, installed. For example, the sox package, which includes several tools for audio processing, also includes a Play binary, which surprisingly plays an audio file. If you do not want to have this hassle, the simplest way is just to create the symlink with another name such as:

ln -s /usr/local/play-1.1/play /usr/local/bin/play-web

Now calling play-web instead of play will for sure always call the Play framework specific script.