Creating a new application

After installing the necessary parts to start with Play, the next step is to create a new application. If you are a Java developer you would most likely start with creating a Maven project, or alternatively create some custom directory structure and use Ant or scripts to compile your sources. Furthermore, you would likely create a WAR file which you could test in your web application server. All this is not the case with the Play framework, because you use a command line utility for many tasks dealing with your web application.

How to do it...

Change into a directory where you want to create a new application and execute the following command:

play new myApp

How it works...

This command will create a new directory named myApp and copy all needed resources for any project into it. After this is done, it should be finished in almost no time. The following file system layout exists inside the myApp directory:

./conf
./conf/dependencies.yml
./conf/routes
./conf/application.conf
./conf/messages
./test
./lib
./public
./app
./app/models
./app/controllers
./app/views

If you are familiar with a rails application, you might be able to orientate very quickly. Basically, the conf directory contains configuration and internationalization files, where as the app folder has a subdirectory for its model definitions. Its controllers contain the business logic and its views, being a mix of HTML and the Play template language. The lib directory contains jar libraries needed to run your application. The public folder contains static content like JavaScript, CSS, and images; and finally the test folder contains all types of tests.

There's more...

Generally speaking, you can add arbitrary content in the form of directories and files in the application directory; for example, the files needed to support Eclipse, or NetBeans will be put here as well. However, you should never remove data which has been copied during the creation of the application unless you really know what you are doing.

Support for various IDEs

You can add support for your IDE by entering: playeclipsify, playidealize, or playnetbeansify. Every command generates the files needed to import a Play application into your favorite IDE.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.67.5