View Source mix needle.new (needle_new v0.1.0)

Creates a new Phoenix project.

It expects the path of the project as an argument.

$ mix needle.new PATH [--app APP] [--module MODULE]

A project at the given PATH will be created. The application name and module name will be retrieved from the path, unless --app or --module is given.

Options

  • --umbrella - generates an umbrella project, which includes two applications, one for the domain, anotehr for the web interface.

  • --app - the name of the OTP application.

  • --module - the name of the base module in the generated skeleton.

  • -v, --version - prints the version of needle.new.* tasks.

Context options

When passing the --no-ecto option, Needle generators such as needle.gen.html, needle.gen.json, needle.gen.live, and needle.gen.context may no longer work as expected as they generate context files that rely on Ecto for the database access. In those cases, you can pass the --no-context flag to generate most of the HTML and JSON files but skip the context, allowing you to fill in the blanks as desired.

Web options

Please check the adapter docs for more information and requirements. Defaults to "cowboy".

  • --no-dashboard - do not include Phoenix.LiveDashboard.

  • --no-assets - do not generate assets.

  • --no-html - do not generate HTML related files.

  • --no-live - do not generate LiveView related files.

When passing the --no-html option, the files generated by needle.gen.html will no longer work, as important HTML components will be missing.

Other options

  • --no-gettext - do not generate gettext files

Examples

$ mix needle.new hello_world

which is equivalent to:

$ mix needle.new hello_world --module HelloWorld

create project without assets and HTML

$ mix needle.new hello_world --no-assets --no-html

which is useful to API projects.

create an umbrella project

$ mix needle.new hello_world --umbrella

which generates the following directory structure and modules:

hello_world_umbrella/   # HelloWorldUmbrella
  apps/
    hello_world/        # HelloWorld
    hello_world_web/    # HelloWorldWeb

You can read more about umbrella projects using the official Elixir guide.