Phoenix v1.3.0-rc.0 Mix.Tasks.Phx.Gen.Html

Generates controller, views, and context for an HTML resource.

mix phx.gen.html Accounts User users name:string age:integer

The first argument is the context name followed by the schema module and its plural name (used for resources and schema).

The above generated resource will add the following files to lib/your_app:

  • a context module in accounts/accounts.ex, serving as the API boundary to the resource
  • a schema in accounts/user.ex, with an accounts_users table
  • a view in web/views/user_view.ex
  • a controller in web/controllers/user_controller.ex
  • default CRUD templates in web/templates/user

As well as a migration file for the repository and test files for generated context and controller features.

Schema table name

By deault, the schema table name will be the plural name, namespaced by the context name. You can customize this value by providing the --table option to the generator.

Read the documentation for phx.gen.schema for more information on attributes and supported options.

Summary

Functions

build(args)
copy_new_files(context, paths, binding)
raise_with_help(msg)
raise_with_help(String.t) :: no_return
run(args)

A task needs to implement run which receives a list of command line args.

Callback implementation for Mix.Task.run/1.