{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"never","params":[],"results":{"codes":[]},"settings":""},"next":{"description":"","pages":[]},"title":"Up And Running","type":"basic","slug":"up-and-running","excerpt":"","body":"The aim of this first guide is to get a Phoenix application up and running as quickly as possible.\n\nBefore we begin, please take a minute to read the [Installation Guide](http://www.phoenixframework.org/docs/installation). By installing any necessary dependencies beforehand, we'll be able to get our application up and running smoothly.\n\nAt this point, we should have Elixir, Erlang, Hex, and the Phoenix archive installed. We should also have PostgreSQL and node.js installed to build a default application.\n\nOk, we're ready to go!\n\nWe can run `mix phoenix.new` from any directory in order to bootstrap our Phoenix application. Phoenix will accept either an absolute or relative path for the directory of our new project. Assuming that the name of our application is `hello_phoenix`, either of these will work.\n\n```console\n$ mix phoenix.new /Users/me/work/elixir-stuff/hello_phoenix\n```\n\n```console\n$ mix phoenix.new hello_phoenix\n```\n\n> A note about [Brunch.io](http://brunch.io/) before we begin: Phoenix will use Brunch.io for asset management by default. Brunch.io's dependencies are installed via the node package manager, not mix. Phoenix will prompt us to install them at the end of the `mix phoenix.new` task. If we say \"no\" at that point, and if we don't install those dependencies later with `npm install`, our application will raise errors when we try to start it, and our assets may not load properly. If we don't want to use Brunch.io at all, we can simply pass `--no-brunch` to `mix phoenix.new`.\n\nNow that we're ready, let's call `phoenix.new` with a relative path.\n\n```console\n$ mix phoenix.new hello_phoenix\n* creating hello_phoenix/README.md\n. . .\n```\n\nPhoenix generates the directory structure and all the files we will need for our application. When it's done, it will ask us if we want it to install our dependencies for us. Let's say yes to that.\n\n```console\nFetch and install dependencies? [Yn] y\n* running npm install\n* running mix deps.get\n```\n\nOnce our dependencies are installed, the task will prompt us to change into our project directory and start our application.\n\n```console\nWe are all set! Run your Phoenix application:\n\n$ cd hello_phoenix\n$ mix phoenix.server\n\nYou can also run it inside IEx (Interactive Elixir) as:\n\n$ iex -S mix phoenix.server\n```\n\nLet's do that now.\n\n```console\n$ cd hello_phoenix\n$ mix phoenix.server\n```\n\n> Note: if this is the first time you are running this command, Phoenix may also ask to install Rebar. Go ahead with the installation as Rebar is used to build Erlang packages.\n\nIf we choose not to have Phoenix install our dependencies when we generate a new application, the `phoenix.new` task will prompt us to take the necessary steps when we do want to install them.\n\n```console\nFetch and install dependencies? [Yn] n\n\nPhoenix uses an optional assets build tool called brunch.io\nthat requires node.js and npm. Installation instructions for\nnode.js, which includes npm, can be found at http://nodejs.org.\n\nAfter npm is installed, install your brunch dependencies by\nrunning inside your app:\n\n    $ npm install\n\nIf you don't want brunch.io, you can re-run this generator\nwith the --no-brunch option.\n\n\nWe are all set! Run your Phoenix application:\n\n    $ cd hello_phoenix\n    $ mix deps.get\n    $ mix phoenix.server\n\nYou can also run it inside IEx (Interactive Elixir) as:\n\n    $ iex -S mix phoenix.server\n```\n\nBy default Phoenix accepts requests on port 4000. If we point our favorite web browser at [http://localhost:4000](http://localhost:4000), we should see the Phoenix Framework welcome page.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"caption\": \"Phoenix Welcome Page\",\n      \"image\": [\n        \"https://files.readme.io/dgQq2PC8SiyitRnHtf7A_welcome-to-phoenix.png\",\n        \"welcome-to-phoenix.png\",\n        \"1702\",\n        \"1262\",\n        \"\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIf your screen looks like the image above, congratulations! You now have a working Phoenix application.\n\nLocally, our application is running in an iex session. To stop it, we hit ctrl-c twice, just as we would to stop iex normally.\n\nThe next step is customizing our application just a bit to give us a sense of how a Phoenix app is put together.","updates":["5497dc5eccb8e70b0008c292","54a6e31521a4791d00b636d0","54cb80fd61698d0d00baf7e7","553e71e08feab90d0059d910","553f67eb76155d0d0050849b"],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"559218ad1da5250d001e9685","user":"5435b410495d5d0800f3a603","githubsync":"","project":"54348ec95b10711400c6c445","__v":1,"createdAt":"2014-10-09T18:43:00.381Z","category":{"sync":{"isSync":false,"url":""},"pages":["559218ad1da5250d001e9684","559218ad1da5250d001e9685","559218ad1da5250d001e9686","559218ad1da5250d001e9687","559218ad1da5250d001e9688","559218ad1da5250d001e9689","559218ad1da5250d001e968a","559218ad1da5250d001e968b","559218ad1da5250d001e968c","559218ad1da5250d001e968d","559218ad1da5250d001e968e","559218ad1da5250d001e968f"],"title":"Guides","slug":"guides","order":1,"from_sync":false,"reference":false,"_id":"559218ad1da5250d001e9671","version":"559218ac1da5250d001e966f","__v":1,"createdAt":"2014-10-09T04:18:04.869Z","project":"54348ec95b10711400c6c445"},"version":{"version":"0.14.0","version_clean":"0.14.0","codename":"","is_stable":false,"is_beta":true,"is_hidden":false,"is_deprecated":false,"categories":["559218ad1da5250d001e9670","559218ad1da5250d001e9671","559218ad1da5250d001e9672","559218ad1da5250d001e9673","559218ad1da5250d001e9674"],"_id":"559218ac1da5250d001e966f","releaseDate":"2015-06-30T04:18:52.132Z","__v":1,"createdAt":"2015-06-30T04:18:52.132Z","forked_from":"5558c642eb56ae2f00f714fc","project":"54348ec95b10711400c6c445"}}
The aim of this first guide is to get a Phoenix application up and running as quickly as possible. Before we begin, please take a minute to read the [Installation Guide](http://www.phoenixframework.org/docs/installation). By installing any necessary dependencies beforehand, we'll be able to get our application up and running smoothly. At this point, we should have Elixir, Erlang, Hex, and the Phoenix archive installed. We should also have PostgreSQL and node.js installed to build a default application. Ok, we're ready to go! We can run `mix phoenix.new` from any directory in order to bootstrap our Phoenix application. Phoenix will accept either an absolute or relative path for the directory of our new project. Assuming that the name of our application is `hello_phoenix`, either of these will work. ```console $ mix phoenix.new /Users/me/work/elixir-stuff/hello_phoenix ``` ```console $ mix phoenix.new hello_phoenix ``` > A note about [Brunch.io](http://brunch.io/) before we begin: Phoenix will use Brunch.io for asset management by default. Brunch.io's dependencies are installed via the node package manager, not mix. Phoenix will prompt us to install them at the end of the `mix phoenix.new` task. If we say "no" at that point, and if we don't install those dependencies later with `npm install`, our application will raise errors when we try to start it, and our assets may not load properly. If we don't want to use Brunch.io at all, we can simply pass `--no-brunch` to `mix phoenix.new`. Now that we're ready, let's call `phoenix.new` with a relative path. ```console $ mix phoenix.new hello_phoenix * creating hello_phoenix/README.md . . . ``` Phoenix generates the directory structure and all the files we will need for our application. When it's done, it will ask us if we want it to install our dependencies for us. Let's say yes to that. ```console Fetch and install dependencies? [Yn] y * running npm install * running mix deps.get ``` Once our dependencies are installed, the task will prompt us to change into our project directory and start our application. ```console We are all set! Run your Phoenix application: $ cd hello_phoenix $ mix phoenix.server You can also run it inside IEx (Interactive Elixir) as: $ iex -S mix phoenix.server ``` Let's do that now. ```console $ cd hello_phoenix $ mix phoenix.server ``` > Note: if this is the first time you are running this command, Phoenix may also ask to install Rebar. Go ahead with the installation as Rebar is used to build Erlang packages. If we choose not to have Phoenix install our dependencies when we generate a new application, the `phoenix.new` task will prompt us to take the necessary steps when we do want to install them. ```console Fetch and install dependencies? [Yn] n Phoenix uses an optional assets build tool called brunch.io that requires node.js and npm. Installation instructions for node.js, which includes npm, can be found at http://nodejs.org. After npm is installed, install your brunch dependencies by running inside your app: $ npm install If you don't want brunch.io, you can re-run this generator with the --no-brunch option. We are all set! Run your Phoenix application: $ cd hello_phoenix $ mix deps.get $ mix phoenix.server You can also run it inside IEx (Interactive Elixir) as: $ iex -S mix phoenix.server ``` By default Phoenix accepts requests on port 4000. If we point our favorite web browser at [http://localhost:4000](http://localhost:4000), we should see the Phoenix Framework welcome page. [block:image] { "images": [ { "caption": "Phoenix Welcome Page", "image": [ "https://files.readme.io/dgQq2PC8SiyitRnHtf7A_welcome-to-phoenix.png", "welcome-to-phoenix.png", "1702", "1262", "", "" ] } ] } [/block] If your screen looks like the image above, congratulations! You now have a working Phoenix application. Locally, our application is running in an iex session. To stop it, we hit ctrl-c twice, just as we would to stop iex normally. The next step is customizing our application just a bit to give us a sense of how a Phoenix app is put together.