{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:41Z","object_id":{"id":1428,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_justenough_otp2","title":{"_type":"trans","tr":{"en":"Add a supervised Erlang worker"}},"uri":"https:\/\/zotonic.com\/id\/1428"},"seq":1},{"created":"2026-10-07T11:13:41Z","object_id":{"id":1576,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_writing_module","title":{"_type":"trans","tr":{"en":"Create a reusable module"}},"uri":"https:\/\/zotonic.com\/id\/1576"},"seq":2}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"subject":{"objects":[{"created":"2026-10-07T11:13:41Z","object_id":{"id":2553,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_tutorial","title":"Tutorial","uri":"https:\/\/zotonic.com\/id\/2553"},"seq":1},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2670,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_erlang_otp","title":"Erlang\/OTP","uri":"https:\/\/zotonic.com\/id\/2670"},"seq":3},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2613,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_development_and_debugging","title":"Development and debugging","uri":"https:\/\/zotonic.com\/id\/2613"},"seq":4}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1429,"is_a":["text","documentation","cookbook"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1429"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cookbook_justenough_otp1","page_url":{"en":"https:\/\/zotonic.com\/cookbook\/1429\/create-an-erlang-application-with-rebar3","x-default":"https:\/\/zotonic.com\/cookbook\/1429\/create-an-erlang-application-with-rebar3"},"preview_url":null,"resource":{"version":34,"pivot_location_lat":null,"title":{"_type":"trans","tr":{"en":"Create an Erlang application with Rebar3"}},"is_authoritative":true,"body":{"_type":"trans","tr":{"en":"<p>This exercise runs outside the Zotonic workspace. Use Erlang\/OTP <strong>28<\/strong> and <a href=\"https:\/\/rebar3.org\/docs\/getting-started\/\">Rebar3<\/a>. Check <code>erl<\/code> and <code>rebar3 version<\/code> before starting.<\/p>\n<h2>Create and compile<\/h2>\n<p>In a directory for practice projects:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-sh\">rebar3 new app garden_counter\ncd garden_counter\nrebar3 compile\nrebar3 shell\n<\/code><\/pre>\n<p>The generated application contains <code>src\/garden_counter.app.src<\/code>, <code>src\/garden_counter_app.erl<\/code>, and <code>src\/garden_counter_sup.erl<\/code>. Erlang source belongs in <code>src<\/code>; generated beam files are under <code>_build\/default\/lib\/garden_counter\/ebin<\/code>.<\/p>\n<p>At the Erlang prompt:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">application:ensure_all_started(garden_counter).\napplication:which_applications().\n<\/code><\/pre>\n<p>Starting an already running application is harmless. Check that <code>garden_counter<\/code> appears in the application list. The application callback starts the supervisor; the generated supervisor initially has no workers.<\/p>\n<p><code>rebar3 shell<\/code> starts a separate practice VM. You can use <code>q().<\/code> to stop <strong>that VM<\/strong>. In a remote Zotonic shell, press <strong>Ctrl-C twice<\/strong> to leave; do not call <code>q().<\/code> or <code>halt().<\/code> there.<\/p>\n<h2>Add a test<\/h2>\n<p>Create <code>test\/garden_counter_tests.erl<\/code>:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">-module(garden_counter_tests).\n-include_lib(&quot;eunit\/include\/eunit.hrl&quot;).\n\napplication_metadata_test() -&gt;\n    case application:load(garden_counter) of\n        ok -&gt; ok;\n        {error, {already_loaded, garden_counter}} -&gt; ok\n    end,\n    {ok, Description} = application:get_key(garden_counter, description),\n    ?assert(is_list(Description)).\n<\/code><\/pre>\n<p>Run <code>rebar3 eunit<\/code>. Expect the test to pass. Continue with the supervised-worker recipe to add useful behaviour. Zotonic applications use Zotonic&#39;s own workspace build; do not run <code>rebar3 new<\/code> inside an existing site directory.<\/p>"}},"slug":"create-an-erlang-application-with-rebar3","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"is_featured":false,"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"category_id":{"id":318,"is_a":["meta","category"],"name":"cookbook","title":{"_type":"trans","tr":{"en":"Cookbook"}},"uri":"https:\/\/test.zotonic.com\/id\/318"},"publication_start":"2022-02-15T10:01:00Z","is_website_redirect":false,"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/cookbook\/justenough-otp1.rst","pivot_location_lng":null,"name":"doc_cookbook_justenough_otp1","is_unfindable":false,"is_published":true,"doc_editorial_edges":{"hasreference":[1428,1576],"subject":[2553,2564,2613,2670]},"summary":{"_type":"trans","tr":{"en":"Build a small standalone OTP application using Erlang\/OTP 28 and Rebar3."}},"pivot_geocode":null,"custom_slug":false,"created":"2020-05-30T05:47:21Z","uri":null,"date_is_all_day":false,"is_dependent":false,"is_page_path_multiple":false,"publication_end":"9999-08-17T12:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_editorial_bundle":true,"creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"seo_noindex":false,"modified":"2026-10-07T11:13:52Z","title_slug":{"_type":"trans","tr":{"en":"create-an-erlang-application-with-rebar3"}}},"uri":"https:\/\/zotonic.com\/id\/1429","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1429"}},"status":"ok"}