This article assumes that you already know Elixir programming language. Further, following are the software you have on your computer.
- Elixir 1.14 or later
- Erlang 24 or later.
- PostgreSQL
If you do not have Elixir and do not know Elixir programming language, please refer the official website to install the Elixir language on your computer and go through this very well written Getting Started docs on Elixir language. This Getting Started covers Elixir in detail and that is what you need before jumping into this series on Phoenix framework. I will explain some Elixir concepts but those will be brief and specific within the context of framework only.
If you do not have Phoenix framework on you computer, please follow this excellent Installation guide. Please install all the suggested software written on this Installation guide. Please also confirm the version of these software as stated above.
-–
Open terminal and run the following command.
This command will scaffold the application with default files and folders. Then it will ask you to install dependencies or not. Press Y
or y
and wait for the dependencies to be installed.
Once the dependencies are installed, you will get further instructions on what to do next. For example, the first thing to do is to cd
into the created hello
application/folder.
Next, open the application or hello
folder into your favorite text-editor. For example, I am using Visual Studio Code.
Then as suggested in further instructions, open config/dev.exs
file. In this file, we are going to adjust the database connection config. Following is a part of the code copied from the config/dev.exs
file that we need to adjust for the same.
As the database is now configured, we can follow the command to create the database and associated tables in it.
The stage is set up. Run the application using the following command.
The application is up and running at http://localhost:4000. Open this URL in the web browser and you should see a landing page with text “Peace of mind from prototype to production.” I like this phrase!
Congratulations! You have just created an application in the Phoenix framework.