Version 22, last updated by dph01 at 20 Jan 00:18 UTC
Getting Started
This Getting Started Guide provides you all need to know to create a simple web application with Lift. First we will take a look at the prerequisites and then we will show you how to create and run a Lift project using different development environments. We won’t cover how to develop the Lift way, because that can be found in the User Guide.
Quick Start
Assuming you have Java 5 or higher installed, you can get a Lift web application running in three simple steps:
- Download the ‘Lift Basic’ template. If you’re using Git:
or manually download and extract the zip or tar.git clone git://github.com/lift/lift_24_sbt.git - Build and run:
cd lift_24_sbt/scala_29/lift_basic ./sbt update ~jetty-run (or sbt.bat update ~jetty-run on Windows) - Open http://localhost:8080 in a web browser to see the application running.
To understand more about what’s going on here, read on …
Prerequisites
Lift is written in Scala which is a modern programming language for the Java virtual machine. You need Java 5 or higher already installed for developing and running Lift projects.
Lift depends on the Servlet API 2.5, hence you need a suitable Servlet container to run a Lift-based web application, e.g. Jetty 6 or 7 or Tomcat 6. However, if you’re using the Lift Basic template (see below), this comes with an embedded Jetty server, so installing a separate container isn’t necessary to get started.
Depending on which development environment you choose it might (Ant) or might not (Maven, SBT, Gradle) be necessary to download the Scala distribution:
- Lift 2.2 – Scala 2.7.7, 2.8.0, 2.8.1
- Lift 2.3 – Scala 2.8.0, 2.8.1
- Lift 2.4-M4 – Scala 2.8.0, 2.8.1, 2.9.0, 2.9.0-1, 2.9.1
- Lift 2.4-SNAPSHOT – Scala 2.8.0, 2.8.1, 2.9.0, 2.9.0-1, 2.9.1
Lift itself is a collection of libraries that you add to your project, so other than downloading the libraries there is no initial ‘installation’ of Lift required. If you’re using a build tool such as SBT, the Lift libraries are downloaded automatically as part of your project’s build process.
Running Your First Lift Web Application.
The easiest way to get your first Lift web application up and running is to download the latest ‘Lift Basic’ template and use SBT to build.This template comprises a navigation bar, user management functionality (Login / Sign Up etc), an index page demonstrating a dynamically generated ‘Hello World’ message and a placeholder for static content. So, it’s an ideal place to start experimenting with your own Lift code.
To get the Lift Basic template, if you’re using Git:
git clone git://github.com/lift/lift_24_sbt.git
or without Git, manually download and extract the zip or tar. Then, to build and run:
cd lift_24_sbt/scala_29/lift_basic
./sbt (sbt.bat on windows)
sbt> update
sbt> ~jetty-run
The Lift Basic template comes with a SBT launcher, so there’s no need to install sbt separately. The command ‘sbt update ~jetty-run’ will download all necessary libraries (Scala, Lift, Jetty, etc), compile the application, and then launch Jetty as an embedded application – there’s no need to install Jetty separately. You can then open http://localhost:8080 in a web browser to see the application running.
For more details on using SBT and other build tools see:
Next Steps
- Simply Lift or Exploring Lift contain good introductions to help you start writing your own Lift code
- Check out further reading, videos, talks etc: http://www.assembla.com/spaces/liftweb/wiki/Resources
- Check out other sample applications (see below).
Other Sample Applications
- http://demo.liftweb.net contains many working demonstrations of Lift features
- The multi-user Chat App from Simply Lift demonstrates some of the powerful features in Lift. The Chat app is also running on the home page of http://demo.liftweb.net
- There are a number of other working sample applications available for download on Github. To run them (Git must be installed first), execute the following from the command line:
git clone git@github.com:lift/examples.git
cd examples
./liftsh (Mac OS/Linux), or liftsh.cmd (Windows)
Wait for the SBT prompt and then:
sbt> projects
sbt> project lift-example (Choose the sample you want from the list)
sbt> update
sbt> jetty-run
Wait for the server to come up and open your browser to localhost:8080
Translations
- Русский: Подготовка к работе с Lift