Code examples and demonstration apps built in Phoenix 1.3 while reading through the Phoenix Guides.
This is not a tutorial. :) I made these code examples in order to have a direct link between content in the guides and code in a working and deployed Phoenix app.
Note that while Phoenix apps are very responsive, these demo apps are deployed to free Heroku dynos which go to sleep after 30 minutes of inactivity. When you click on a demo link, there will be a delay while the dyno activates.
Contact: @smeade.
- Up and Running
- Adding Pages
- A purely static page
- Another New Page: Sending Parameters
- Routing
- Resources guide | code | demo
- Forward guide | code | demo | demo
- Path Helpers guide | code | demo
- Nested Resources guide | code | demo
- Scoped Routes guide | code | demo
- Pipelines guide
- The :browser and :api Pipelines code
- Creating New Pipelines code: pipeline | code: plug | demo
- Channel Routes guide
- Plug
- Function Plugs guide | code: function | code: plug | demo
- Module Plugs guide | code: module | code: plug
- Endpoint
- Controllers
- Views
- Templates
- Channels
- Channels Sample application
- Overview guide | code | demo
- Uncomment the “room:” channel definition code
- Define a HelloWeb.RoomChannel module code
- Joining Channels guide
- authorize clients to join topic code
- set our room name to “room:lobby” code
- join channel code
- import assets/js/socket.js code
- add containers to hold our chat messages code
- [x] push an event over the channel with the message body code
- listen for new messages and append them to our messages container code
- Handle Incoming Events guide | code
- Ecto
- Overview Phoenix guide | Ecto Guide
- Postgres configuration code
- Generate an Ecto schema code: schema | code: migration
- Changesets and Validations guide | ecto guide | code: cast | code: validate
- Data Persistence guide | ecto guide
- Contexts
- Overview guide
- Adding an Accounts Context With Generators guide | code:controller | code:context | code:schema | demo
- In-context Relationships: e.g. Credential belongs_to User
- Overview guide
- mix phx.gen.context Accounts Credential... code
- has_one/belongs_to code:belongs_to | code:has_one
- load association data code
- add association changeset code - [x] add association to user edit/create form code
- Adding Account Functions: e.g. Sessions
- Cross-context dependencies: e.g. CMS.Author <-> Accounts.User
- Cross-context data: e.g. CMS.Author <-> Accounts.User
- Adding CMS functions: e.g. page views
- Mix Tasks
- Custom Errors
- Overview guide
- Introduction to Testing
- Overview guide
- Running Tests Using Tags guide | code:moduletag | code:tag
- Randomization guide
- Testing Schemas
- Testing Controllers
- Testing Channels
- Overview guide
- Generate a channel and tests code
- Testing a Synchronous Reply code:test | code:channel
- Testing a Broadcast code:test | code:channel
- Testing an Asynchronous Push from the Server code:test | code:channel
We'll create a demo app for each branch of this repo. To do so, we need to:
- Tell Phoenix of the updated Heroku URL
- Create the Heroku application and add buildpacks
- Create environment variables in the new app in Heroku
- Add a git remote and deploy
Update the host in prod.exs
.
url: [scheme: "https", host: "phx-010-ecto.herokuapp.com", port: 443],
$ heroku create phx-010-ecto --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir.git"
$ heroku buildpacks:add https://github.com/gjaldon/heroku-buildpack-phoenix-static.git -a phx-010-ecto
$ heroku addons:create heroku-postgresql:hobby-dev -a phx-010-ecto
$ heroku config:set POOL_SIZE=18 -a phx-010-ecto
$ mix phx.gen.secret
$ heroku config:set -a phx-010-ecto SECRET_KEY_BASE="insertkeyhere"
$ git remote add phx-010-ecto https://git.heroku.com/phx-010-ecto.git
$ git push phx-010-ecto phx-010-ecto:master
$ heroku open -a phx-010-ecto
heroku run "POOL_SIZE=2 mix ecto.migrate" -a phx-011-contexts
- Official website: http://www.phoenixframework.org/
- Guides: http://phoenixframework.org/docs/overview
- Docs: https://hexdocs.pm/phoenix
- Mailing list: http://groups.google.com/group/phoenix-talk
- Source: https://github.com/phoenixframework/phoenix