Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# editorconfig.org
# from https://devhints.io/editorconfig
root = true

[*]
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
66 changes: 58 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,70 @@
# Hello

To start your Phoenix app:
To start your Phoenix server:

* Install dependencies with `mix deps.get`
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Install Node.js dependencies with `npm install`
* Start Phoenix endpoint with `mix phoenix.server`
* Create and migrate your database with `mix ecto.setup`
* Install Node.js dependencies with `npm install` inside the `assets` directory
* Start Phoenix endpoint with `mix phx.server`

Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.

Ready to run in production? Please [check our deployment guides](http://www.phoenixframework.org/docs/deployment).
Ready to run in production? Please [check our deployment guides](https://hexdocs.pm/phoenix/deployment.html).

## Learn more

* Official website: http://www.phoenixframework.org/
* Guides: http://phoenixframework.org/docs/overview
* Official website: https://www.phoenixframework.org/
* Guides: https://hexdocs.pm/phoenix/overview.html
* Docs: https://hexdocs.pm/phoenix
* Mailing list: http://groups.google.com/group/phoenix-talk
* Forum: https://elixirforum.com/c/phoenix-forum
* Source: https://github.com/phoenixframework/phoenix

## Phoenix Diagram

A simplified view of a Phoenix Web Application

```
connection
|> endpoint
|> router
|> pipelines # typically one for browser requests, another for json/api requests
|> controller
```

Controller as pipe chain of functions

```
connection
|> controller
|> common_services
|> action
```

```
connection # Plug.Conn
|> endpoint # lib/hello/endpoint.ex
|> browser # web/router.ex
|> HelloController.world # web/controllers/hello_controller.ex
|> HelloView.render( # web/views/hello_view.ex
"world.html") # web/templates/hello/world.html.eex
```

> Plugs are functions. Your web applications are pipelines of plugs.

## Commands

initial setup

```bash
$ mix phoenix.new . --app hello
$ mix ecto.create
$ mix phoenix.server
```

## Editor

![](./editor.png)

## Browser

![](./browser.png)
Binary file added browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ $ dc up
```

visit <http://localhost:4000/>

open interactive elixir (iex) and load the `mix phoenix.server` script

```bash
$ dc run app \
iex -S mix phoenix.server
```
7 changes: 7 additions & 0 deletions web/controllers/hello_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Hello.HelloController do
use Hello.Web, :controller

def world(conn, %{"name" => name}) do
render conn, "world.html", name: name
end
end
1 change: 1 addition & 0 deletions web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule Hello.Router do
scope "/", Hello do
pipe_through :browser # Use the default browser stack

get "/hello/:name", HelloController, :world
get "/", PageController, :index
end

Expand Down
4 changes: 4 additions & 0 deletions web/templates/hello/world.html.eex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>
From template: Hello,
<%= String.capitalize(@name) %>!
</h1>
3 changes: 3 additions & 0 deletions web/views/hello_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule Hello.HelloView do
use Hello.Web, :view
end