Giter VIP home page Giter VIP logo

learn_phoenix's Introduction

LearnPhoenix

To start your Phoenix server:

  • Run mix setup to install and setup dependencies
  • Start Phoenix endpoint with mix phx.server or inside IEx with iex -S mix phx.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more

Notes

lib/project_name

  • Business logic and business domain
  • Inside lib/learn_phoenix lives all the "Model" files in MVC architecture
  • They interact directly with the DB

lib/project_name_web

  • Responsible for exposing business domain to the world, through a web app
  • It holds View and Controllers

Controllers actions

  • Actions in controllers has a conn argument
  • conn is a struct which holds data about request

Assigns

https://hexdocs.pm/phoenix/request_lifecycle.html#another-new-template

The values we passed to the view from the controller are collectively called our "assigns". We could access our messenger value via assigns.messenger but through some metaprogramming, Phoenix gives us the much cleaner @ syntax for use in templates.

Pipelines

  • Pipelines allow a set of plugs to be applied to different sets of routes.

Verified Routes

  • ~p This sigil returns an error if the Route doesn't match

Ecto

mix phx.gen.schema User users name:string email:string

  iex -S mix

  alias LearnPhoenix.User
  changeset = User.changeset(%User{}, %{})
  alias LearnPhoenix.{Repo, User}
  Repo.insert(%User{email: "[email protected]"})
  Repo.all(User)
  import Ecto.Query
  Repo.all(from u in User, select: u.email)
  Repo.one(from u in User, where: ilike(u.email, "%1%"), select: count(u.id))

learn_phoenix's People

Contributors

fdipersia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.