0Pricing
Elixir & Phoenix: Scalable Backend Development · 강의

Phoenix 프로젝트 설정과 구조

새 Phoenix 프로젝트를 만들고 디렉터리 구조를 이해하며 라우터와 컨트롤러 같은 핵심 구성 요소를 살펴봅니다.

Phoenix 프로젝트 설정과 구조은(는) CoddyKit의 무료 Elixir & Phoenix: Scalable Backend Development 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Elixir & Phoenix: Scalable Backend Development 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Elixir & Phoenix: Scalable Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Welcome to Phoenix!

Hello! In this lesson, we'll begin our journey with Phoenix, Elixir's powerful web framework. Phoenix helps you build robust, high-performance web applications and APIs.

It leverages the speed and fault-tolerance of the Erlang Virtual Machine (BEAM) through Elixir, making it ideal for real-time features and concurrent systems.

Why Choose Phoenix?

Phoenix combines the elegance of Elixir with the reliability of Erlang/OTP. This means your applications can handle many concurrent users with low latency and are highly resilient to failures.

It's a fantastic choice for building anything from simple websites to complex real-time applications like chat rooms or live dashboards.

Setup Your Environment

Before we create a Phoenix project, ensure you have Elixir and Erlang installed on your system. You can check your versions using the commands below.

If you don't have them, consider using asdf for easy installation and version management.

elixir -v
mix -v

Generating a New Project

The easiest way to start a new Phoenix project is by using the mix phx.new command. This command sets up a new application with all the necessary files and dependencies.

Let's create our first project, named hello_phoenix:

mix phx.new hello_phoenix

Understanding Project Structure

After running mix phx.new hello_phoenix, a new directory named hello_phoenix is created. Inside, you'll find a well-organized set of folders and files.

This structure helps keep your code modular and maintainable as your application grows.

Key Project Folders

Let's look at some of the top-level directories:

  • assets/: Contains your frontend files like CSS, JavaScript, and images.
  • config/: Holds configuration files for different environments (development, test, production).
  • priv/: Stores private application resources, such as database migrations and static files not served directly.

`lib/` - Your Application Code

The lib/ directory is the heart of your Elixir application. For Phoenix projects, it usually contains two main sub-directories:

  • lib/hello_phoenix/: Your core application logic and business rules.
  • lib/hello_phoenix_web/: Web-specific components like controllers, views, and routers.

This separation helps keep your web interface distinct from your core logic.

hello_phoenix/
├── lib/
│   ├── hello_phoenix/
│   └── hello_phoenix_web/

Introducing the Router

Inside lib/hello_phoenix_web/, you'll find router.ex. The router is like the traffic cop of your web application.

It defines how incoming web requests (like visiting a URL) are mapped to specific actions within your application, typically handled by controllers.

# lib/hello_phoenix_web/router.ex
defmodule HelloPhoenixWeb.Router do
  use HelloPhoenixWeb, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :put_root_layout, {HelloPhoenixWeb.LayoutView, :root}
    plug :protect_from_forgery
    plug :put_secure_browser_headers
  end

  scope "/", HelloPhoenixWeb do
    pipe_through :browser

    get "/", PageController, :index
  end
end

Running Your Phoenix App

After generating your project and installing dependencies (mix deps.get), you can start the development server. This compiles your code and makes your application accessible in your browser, usually at localhost:4000.

Navigate into your project directory first!

cd hello_phoenix
mix phx.server

Quick Check: Project Structure

The mix phx.new command creates a standard Phoenix project. Which directory is typically used for frontend assets like CSS and JavaScript?

Lesson Summary

Great job! You've successfully created your first Phoenix project using mix phx.new. We explored the basic directory structure, including assets/, config/, lib/, and priv/.

You now have an understanding of where your core application logic lives (lib/hello_phoenix) and where web-specific components reside (lib/hello_phoenix_web), including the crucial router.ex. Next, we'll dive deeper into how routing works and how controllers handle requests!

자주 묻는 질문

“Phoenix 프로젝트 설정과 구조” 강의는 무료인가요?

네 — “Phoenix 프로젝트 설정과 구조” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Elixir & Phoenix: Scalable Backend Development 강의 전체를 잠금 해제할 수 있습니다. Elixir & Phoenix: Scalable Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.

“Phoenix 프로젝트 설정과 구조”에서 뭘 배우나요?

새 Phoenix 프로젝트를 만들고 디렉터리 구조를 이해하며 라우터와 컨트롤러 같은 핵심 구성 요소를 살펴봅니다. 브라우저에서 직접 실행하는 실습 코드로 Elixir & Phoenix: Scalable Backend Development을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Elixir & Phoenix: Scalable Backend Development을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Elixir & Phoenix: Scalable Backend Development은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“Phoenix 프로젝트 설정과 구조” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Elixir & Phoenix: Scalable Backend Development 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Elixir & Phoenix: Scalable Backend Development 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Phoenix 프로젝트 설정과 구조
  2. 라우팅, 컨트롤러 및 플러그
  3. 뷰, 템플릿 및 LiveView 기초
  4. Phoenix Channels로 실시간 기능 구현하기
← Elixir & Phoenix: Scalable Backend Development(으)로 돌아가기