Brad

Brad

Programming Phoenix LiveView:

Two things:

1.
The book is written to,. or alludes to the following…

Open up an operating system shell and navigate to the parent directory for your project. Then, type:
mix phx.new pento --live

[pp_liveview] ➔ mix phx.new pento --live * creating pento/config/config.exs

  • creating pento/config/dev.exs
  • creating pento/config/prod.exs

    Fetch and install dependencies? [Yn] Y
  • running mix deps.get

    The mix phx.new command runs the Phoenix installer for a standard Phoenix project, and the --live switch adds the library dependencies, configuration, and assets we’ll need to build live views.

As we work through this book, we’ll point out the bits that this --live switch adds to our project, and we’ll examine the directory structure in detail over time. For now, know that backend code goes in the lib/pento directory, the web- based assets like .css and .js files go in assets, and the web-based code all goes in the lib/pento_web directory.
Create The Database and Run The Server
At the bottom of the installation output, you’ll find a few extra instructions that look something like this:

We are almost there! The following steps are missing:
$ cd pento
$ mix deps.get
$ cd assets && npm install && node node_modules/webpack/bin/webpack.js
–mode development
Then configure your database in config/dev.exs and run:
$ mix ecto.create

I think too many assumptions are made at this step, especially if you are rusty. mix ecto.create errors out. You need to be specific about what those configs need to be set at in config/dev.exs. Also which version of PostgreSQL? A suggestion GUI-driven version probably would be a good idea to help standardize this.

2.
The book above (#1) says one thing but the printout I get from running mix phx.new pento --live produced s slightly different set of instructions at the end of the project generation.

(base) bradhutchins@MacBook-Pro Programming-Phoenix-LiveView % mix phx.new pento --live

  • creating pento/config/config.exs
  • creating pento/config/dev.exs
  • creating pento/config/prod.exs
  • creating pento/config/prod.secret.exs
  • creating pento/config/test.exs
  • creating pento/lib/pento/application.ex
  • creating pento/lib/pento.ex
  • creating pento/lib/pento_web/channels/user_socket.ex
  • creating pento/lib/pento_web/views/error_helpers.ex
  • creating pento/lib/pento_web/views/error_view.ex
  • creating pento/lib/pento_web/endpoint.ex
  • creating pento/lib/pento_web/router.ex
  • creating pento/lib/pento_web/telemetry.ex
  • creating pento/lib/pento_web.ex
  • creating pento/mix.exs
  • creating pento/README.md
  • creating pento/.formatter.exs
  • creating pento/.gitignore
  • creating pento/test/support/channel_case.ex
  • creating pento/test/support/conn_case.ex
  • creating pento/test/test_helper.exs
  • creating pento/test/pento_web/views/error_view_test.exs
  • creating pento/lib/pento/repo.ex
  • creating pento/priv/repo/migrations/.formatter.exs
  • creating pento/priv/repo/seeds.exs
  • creating pento/test/support/data_case.ex
  • creating pento/lib/pento_web/templates/layout/root.html.leex
  • creating pento/lib/pento_web/templates/layout/app.html.eex
  • creating pento/lib/pento_web/templates/layout/live.html.leex
  • creating pento/lib/pento_web/views/layout_view.ex
  • creating pento/lib/pento_web/live/page_live.ex
  • creating pento/lib/pento_web/live/page_live.html.leex
  • creating pento/test/pento_web/views/layout_view_test.exs
  • creating pento/test/pento_web/live/page_live_test.exs
  • creating pento/lib/pento_web/gettext.ex
  • creating pento/priv/gettext/en/LC_MESSAGES/errors.po
  • creating pento/priv/gettext/errors.pot
  • creating pento/assets/webpack.config.js
  • creating pento/assets/.babelrc
  • creating pento/assets/js/app.js
  • creating pento/assets/css/app.scss
  • creating pento/assets/package.json
  • creating pento/assets/static/favicon.ico
  • creating pento/assets/css/phoenix.css
  • creating pento/assets/static/images/phoenix.png
  • creating pento/assets/static/robots.txt

Fetch and install dependencies? [Yn] Y

  • running mix deps.get
  • running mix deps.compile
  • running cd assets && npm install && node node_modules/webpack/bin/webpack.js --mode development

We are almost there! The following steps are missing:

$ cd pento

Then configure your database in config/dev.exs and run:

$ mix ecto.create

Start your Phoenix app with:

$ mix phx.server

You can also run your app inside IEx (Interactive Elixir) as:

$ iex -S mix phx.server

Marked As Solved

SophieDeBenedetto

SophieDeBenedetto

Author of Programming Phoenix LiveView

Thanks for pointing this out @Brad, your feedback is super helpful :slight_smile:

You can look for some updated info on installing and configuring Postgres in the next Beta release. As for seeing slightly different output from the mix phx new pento --live command–that would likely be due to your using a different Phoenix version than the one with which the Pento app is generated. Some added text to clarify that this might be the case for readers will probably help here. Look for that in the upcoming release as well!

Where Next?

Popular Pragmatic Bookshelf topics Top

New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New

Sub Categories: