ZX: Create a New Project

To create a project from scratch issue the "create project" command and follow the prompts. ZX will walk you through the process and explain what is being done, populating an OTP compliant project template based on the project type you choose.

ceverett@icecream:~/code$ zx create project

In this example a CLI application called "foo" has been created in the default "otpr" realm (though it is not yet registered with the OTPR prime node -- it still only exists locally), so we see the following:

AppMod: foo
Writing app file: ebin/foo.app
Project otpr-foo-0.1.0 initialized.

NOTICE:
This project is currently listed as having no dependencies.
If this is not true then run `zx set dep DepID` for each current dependency.
(run `zx help` for more information on usage)

The foo project can be built and executed using the zx rundir foo [args] command. CLI program templates are very minimal, starting with a basic "Hello, World!" and simply printing whatever args are passed to it:

ceverett@icecream:~/code$ zx rundir foo some args go here
Recompile: src/foo
Hello, World! Args: ["some","args","go","here"]

If we enter the foo project's base directory we can also run it using the zx runlocal [args] command:

ceverett@icecream:~/code$ cd foo
ceverett@icecream:~/code/foo$ ls
Emakefile  LICENSE  ebin  src  zomp.meta
ceverett@icecream:~/code/foo$ zx runlocal some more args here
Hello, World! Args: ["some","more","args","here"] 

Note that the first time we ran foo the message "Recompile src/foo" was shown, but not the second time. Once code has been built it will not be rebuilt unless the .beam (compiled) object files are missing or the source files have changed. For large projects this means that the first time running them may take a few seconds to get everything built, but subsequent executions are immediate.

At this point you can hop straight into the src/ directory and start hacking away!

Note that the most common type of Erlang project is, of course, networked back-end services, and if you choose "Traditional Erlang service application" as your template type you will wind up with a full-blown, supervised, OTP compliant telnet echo server as your starting point. If you are just starting out with Erlang it is advisable to start with escripts or CLI programs until you get your feet wet.

If you are using git/GitLab for version control (who isn't?) then you should "git init" the project in the normal way now.

After you have initialized your project and have a repository URL you can run zx update meta to adjust project metadata such as the author name, description, search tags, URLs associated with the project, etc.

By default the package name of a new templated project is also used as the "app mod" name (the place the Erlang runtime tries to start executing). This can be changed, of course, but it is the way new projects are templated and the most common arrangement found in the wild.