Setting up Enonic
In this chapter, we will create an Enonic app based on the Headless Movie DB project, and play around with the Headless API
|For an in-depth introduction to Enonic, visit the official Enonic Developer 101 guide.|
Enonic at a glance
Our platform is called Enonic XP (XP, or Enonic for short).
Enonic XP allows you to install and run one or more applications in a single instance.
You can discover ready to run applications on Enonic Market, or you may build your own, like we will be doing in this tutorial.
Each app may provide specific functionality. It may for instance be everything you need for a large website, or provide specific services, such as an API. An app is given a unique app name when it’s built.
|Useful terminology: A sandbox is a local Enonic server running on your laptop. Apps are built from projects which are basically a folder that contains the app’s source code. Once it is built, it can be deployed to the sandbox - where it will be started and made available.|
Apps typically ship with one or more content types. Content types typically define data structures, JSON style. Each content type gets a unique name which is automatically pre-fixed with the app-name. e.g.
Content types are used to create content items. Content is commonly created and handled via Enonic’s Content Studio. Content may be organised in tree structures, which can be useful both for internal, and external purposes - as you will see in this tutorial.
Content items get a unique path name - similar to a filename - and a human-friendly displayName.
Content items can exist in two different branches: When creating or editing in Content Studio, you’re always working in the
draft branch. When publishing, new items and changes are copied to the
The Headless Movie Database
With Enonic, you may obviously create your own content model, but to save time in this tutorial, we’ll be using a demo-app known as the Headless Movie Database (HMDB) as our starting point.
HMDB ships with a pre-defined content-model and some useful sample content.
The Guillotine API
Finally, to expose you content, we’ll install an app called Guillotine. Once installed, Guillotine automatically exposes a GraphQL API for your applications and content.
Let’s get going!
Task: Create application from template
Install the Enonic CLI (follow link for instructions).
Create a new project using the "Headless movie database" as your template:
Run the following command from your terminal
enonic project create -r app-hmdb
Stick with the standard values and keep the suggested project name
com.example.myprojectfor the examples in the tutorial to work properly. This will be referred to as app name later in this tutorial.
Deploy the application by running this command from your freshly created project folder.
enonic project deploy
When asked to create a sandbox (a local instance of Enonic XP), just give it a name i.e.
next-demoand go with the default values. When the sandbox has started, it outputs some server logs, and the sample content gets imported automatically.
Task: Install Content Studio
Navigate to http://localhost:8080 and log in to the admin console (you don’t have to create a user for this tutorial).
Install Content Studio (it’s an XP app of its own) by completing the XP Tour , or via the
From the XP menu, open
Content Studio, and choose the
Headless demoproject if needed. You should see something like this:
Some items have a default preview. That’s okay for now - as we will customize this preview later.
Congrats on setting up the Enonic development environment
With the SDK running, lets have a look at the headless API.