Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Getting Started With Phoenix - ElixirConf UY

Getting Started With Phoenix - ElixirConf UY

Elaine Naomi

November 11, 2022
Tweet

More Decks by Elaine Naomi

Other Decks in Programming

Transcript

  1. Getting Started with PHOENIX ElixirConf UY 2022

  2. W ORKSHOP Montevideo, UY

  3. W ORKSHOP

  4. railsgirls.com.br

  5. Elixir + Ruby

  6. None
  7. Lessons Learned from Elixir Learning Paths https://www.youtube.com/watch?v=I1jUWz1RP2U https://speakerdeck.com/elainenaomi/elixir-conf-eu-lessons-learned-from-elixir-learning-paths

  8. Code Smells, Refatoração e Elixir https://www.youtube.com/watch?v=3-1PCurON4Q https://speakerdeck.com/elainenaomi/elixir-brasil-2020-code-smells-refactoring-e-elixir

  9. https://github.com/lucasvegi/Elixir-Code-Smells a scientific research about code smells in Elixir

  10. olá

  11. São Paulo / Brazil

  12. Software Engineer/Developer (since 2008) B.Sc. in Computer Engineering M.Sc. in

    Computer Science ELAINE NAOMI WATANABE twitter.com/elaine_nw speakerdeck.com/elainenaomi linkedin.com/in/elainenaomi
  13. None
  14. The RealReal - Elixir Adoption Story youtube.com/watch?v=sTs_4T1ufLY

  15. The RealReal is one of the ElixirConf UY's sponsors

  16. None
  17. None
  18. therealreal.com/careers including Fully Remote opportunities

  19. None
  20. DAY 1: WORKSHOP

  21. None
  22. None
  23. Goal: to build a web app with Phoenix

  24. None
  25. WHAT IS A WEB FRAMEWORK?

  26. https://en.wikipedia.org/wiki/Web_framework Web Framework It is standard way to build and

    deploy web applications Automation of common activities performed in web development For example, providing libraries for database access, templating frameworks, session management, often focusing on code reuse
  27. https://en.wikipedia.org/wiki/Web_framework Web Framework It is standard way to build and

    deploy web applications Automation of common activities performed in web development For example, providing libraries for database access, templating frameworks, session management, often focusing on code reuse
  28. https://en.wikipedia.org/wiki/Web_framework Web Framework It is standard way to build and

    deploy web applications Automation of common activities performed in web development For example, providing libraries for database access, templating frameworks, session management, often focusing on code reuse
  29. None
  30. WHAT IS PHOENIX?

  31. Phoenix Framework Web framework created in 2014 for Elixir programming

    language Creator: Chris McCord Latest version: 1.6.15 Released date: 2022-10-26
  32. Phoenix Framework Web framework created in 2014 for Elixir programming

    language Creator: Chris McCord Latest version: 1.6.15 Released date: 2022-10-26
  33. ELIXIR

  34. Elixir + Erlang VM Highly Scalable and Concurrent Applications

  35. blog.whatsapp.com/1-million-is-so-2011 ERLANG 2 million connections on a single node

  36. 2 million connections on a single node phoenixframework.org/blog/the-road-to-2-million-websocket-connections ELIXIR

  37. https://web.archive.org/web/20181011093614/https://www.techworld.com/apps-wearables/how-elixir-helped-bleacher-re port-handle-8x-more-traffic-3653957/

  38. From 150 servers to 5!

  39. Productivity and Performance for Developers

  40. Convention over Configuration

  41. Concurrency in all environments, including tests and development

  42. With new tools to build modern web app

  43. Real Time Web

  44. None
  45. None
  46. EXPECTATIONS

  47. Introducción a Phoenix

  48. our toy program for this workshop

  49. None
  50. github.com/elainenaomi/taskify

  51. AGENDA

  52. ➔ Building a landing page ➔ Adding the authentication system

    ➔ Creating, reading, updating, deleting user tasks ➔ Adding sub-tasks to user tasks ➔ Building the task status from sub-tasks ➔ Deploying on fly.io
  53. SETUP

  54. elixir -v

  55. ➔ Elixir 1.14.1 ➔ Erlang 24.3.4.6

  56. postgres -V

  57. mix archive.install hex phx_new

  58. mix phx.new -v

  59. TASK #001

  60. mix phx.new taskify

  61. mix phx.server

  62. None
  63. Live Dashboard

  64. None
  65. TASK #002

  66. page title new path update the content, including logo image

  67. None
  68. TASK #003

  69. Log in Sign Up

  70. None
  71. TASK #004

  72. Finally building tasks!

  73. logged user

  74. None
  75. Ecto != ORM

  76. None
  77. TASK #005

  78. Nested resource: tasks/:task_id/sub_tasks logged user

  79. None
  80. TASK #006

  81. None
  82. sub-tasks status on task list

  83. TASK #007

  84. None
  85. Deploying on Fly.io

  86. I'm using fly.io for this toy app because of the

    simple setup Installing flyctl command For example, via homebrew for mac os brew install flyctl Creating an account flyctl auth signup Launching the app cd taskify fly launch Stopping the app fly scale count 0 https://fly.io/docs/hands-on/install-flyctl/ https://fly.io/docs/elixir/getting-started/
  87. taskify.fly.dev

  88. Deploying with Releases

  89. MIX_ENV=prod mix release https://hexdocs.pm/mix/1.14.1/Mix.Tasks.Release.html

  90. mix phx.gen.release --docker

  91. build time vs runtime

  92. config/config.exs vs config/runtime.ex https://elixir-lang.org/getting-started/mix-otp/config-and-releases.html#configuration

  93. No Support to Hot Code Upgrades

  94. "Given most teams can use other techniques that are language

    agnostic to upgrade their systems, such as Blue/Green deployments, Canary deployments, Rolling deployments, and others, hot upgrades are rarely a viable option" https://hexdocs.pm/mix/1.14.1/Mix.Tasks.Release.html#module-hot-code-upgrades
  95. https://blog.miguelcoba.com/series/deploying-elixir

  96. WRAPPING UP

  97. ➔ Introduction to Phoenix Request Life-Cycle ➔ Introduction to Phoenix

    generators ➔ Introduction to Ecto: migrations, Ecto schema and validations, Ecto queries ➔ Introduction to authentication with mix phx.gen.auth ➔ An overview of data integrity :) ➔ Deployment with fly.io
  98. in 2 hours!

  99. REFERENCES

  100. None
  101. https://elixirforum.com/

  102. None
  103. ADDITIONAL REFERENCES

  104. None
  105. https://medium.com/very-big-things Clarity | Saša Jurić | ElixirConf EU 2021 https://www.youtube.com/watch?v=6sNmJtoKDCo

  106. https://ulisses.dev/

  107. Writing extensible functional code - Renan Ranelli https://www.youtube.com/watch?v=1HXMUI7tiCQ

  108. SOLID Elixir • Georgina McFadyen • GOTO 2018 https://www.youtube.com/watch?v=rmftOs2BzgU

  109. None
  110. None
  111. github.com/podium/elixir-secure-coding

  112. github.com/podium/elixir-secure-coding

  113. !!Con 2019- Tail Call Optimization: The Musical!! by Anjana Vakil

    & Natalia Margolis https://www.youtube.com/watch?v=-PX0BV9hGZY
  114. None
  115. https://pesquisecomelixir.com.br/

  116. https://github.com/lucasvegi/Elixir-Code-Smells

  117. O Elixir do futuro, com Charlotte Lorelei Oliveira https://pt-br.eventials.com/locaweb/o-elixir-do-futuro-com-charlotte-lorelei-oliveira/ ELIXIR

  118. MY CONTRIBUTIONS

  119. ELIXIR youtube.com/ElixirLabOrg

  120. ELIXIR

  121. ELIXIR

  122. CARNIVAL EDITION ELIXIR

  123. https://sourcelevel.io/code-review-ebook

  124. https://github.com/elainenaomi/taskify

  125. speakerdeck.com/elainenaomi elainenaomi.dev Muito obrigada illustrations from undraw.co translation: muchas gracias