In this recipe we'll create our first project.
We'll begin with the Ember CLI tool to create our first project.
$ ember new my-project
This will create a brand new project called my-project
. The project structure will have everything that we need to get started.
$ cd my-project $ ember server
The ember server
command will start up a web server on port 4200. You can access this port by opening http://localhost:4200
. You should see the default Welcome to Ember website.
It is a good idea to keep the Ember server running while developing your application. Ember CLI uses a tool called LiveReload to refresh the web browser when changes are made. This can be useful to see how new changes are affecting your application. To run LiveReload, simply type ember server
. This will start the server with LiveReload.
--port
argument:$ ember server --port 1234
This will start the server on port 1234
instead of the default 4200.
--proxy
argument. This will proxy all Asynchronous JavaScript and XML (Ajax) requests to the given address. Let's say that we have a node server running on port 8080
. We can run the server as follows:$ ember server --proxy http://127.0.0.1:8080
For every Ajax request, Ember now will send these requests to the localhost at port 8080
.
The ember server
command creates a Node.js Express server. This server uses LiveReload and refreshes the web page whenever any changes are made. The server command accepts different arguments, including --proxy
and --port
.
When running the server, you have access to tests. After you start the server, you'll have access to the
QUnit interface. QUnit is a JavaScript unit testing framework. It is used to run your integration and acceptance tests. To access the interface, navigate your browser to http://localhost:4200/tests
. This will show all your tests in the project. From here, you can see which tests passed and which failed. We will cover this in the later chapters: