Setting up Enonic
Contents
In this chapter, we will create an Enonic app based on the Introduction
starter kit and launch a local development environment of the platform.
For an in-depth tutorial on Enonic, visit the official Enonic Developer 101 guide. |
Enonic at a glance
Our platform is called "Enonic XP" (or simply "Enonic").
Enonic apps
Enonic applications are essentially how you extend and customize the platform. Enonic XP allows you to install and run one or more applications in a single platform instance.
Discover ready-to-run applications on Enonic Market, or build your own. You will create an app of your own in this tutorial.
An application typically provides specific functionality. It may for instance produce everything needed for a large website, or provide specific microservices, such as an API. An app is given a unique app name when it’s built.
Useful terminology: A sandbox is a local instance of Enonic XP platform running on your PC/laptop. Once an app is built, it can be deployed to the sandbox - where it will be started and made available. |
Content
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. <appName>:<contentTypeName>
.
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.
Each content items has a unique name within it’s path - similar to files and folders in a filesystem. It also has a human-friendly display name.
Content items exist in two different branches. When creating or editing in Content Studio, you’re always working in the draft
branch. When published, changes will be copied to the master
branch.
The Movie Database
With Enonic, you can obviously create your own content model from scratch, but to save time you’ll be using Introduction app as a template.
This app ships with a pre-defined content-model, and sample content from the cinematic industry.
Let’s get going!
Task: Install the Enonic CLI
Install the Enonic CLI (follow link for instructions).
Task: Create and start a sandbox
-
Create a sandbox called
mysandbox
by running this command in your terminal:enonic sandbox create mysandbox -t essentials -f
-f
flag will force using the most recent release of Enonic XP. -
Start the sandbox with this command:
enonic sandbox start mysandbox --dev
Dev mode optimizes the development process.
Task: Create and deploy an app
Let the sandbox run in the first terminal window, and open a new terminal window for the following commands. |
-
Create a new project using the
Introduction
app as a starter, by running the following command in your terminal:enonic project create -r tutorial-intro -n com.example.myproject -d myproject -v 1.0.0 --sb mysandbox
This command will:
-
use the GitHub repo
github.com/enonic/tutorial-intro
as a starter -
to create an app called
com.example.myproject
with version1.0.0
-
in the directory
myproject
-
and link it to
mysandbox
which you created earlier
-
-
Deploy the application
Assuming
mysandbox
is still running in another Terminal window, run these commands:cd myapp enonic dev
The last command will build and deploy the app to mysandbox
, then start watching for changes in the code to automatically rebuild as you work on it.
Look for the following output to verify that the app has been built: BUILD SUCCESSFUL in 6s 3 actionable tasks: 3 executed Waiting for changes to input files... |
Task: Open Admin dashboard
Let’s have a look at the sandbox' web interface. Open http://localhost:8080 in your browser (or just click the link).
You should now see the Welcome page:
The Welcome page provides an overview of the sandbox, including installed application and standard configuration files.
My App should be in the list, together with other applications that were automatically installed when you created the sandbox. |
Click btn:[Log In as Guest] to open the XP admin dashboard. You should now see the following:
You are now on the admin dashboard. The right hand menu (aka XP menu
) enables navigation between admin tools. Admin tools may be injected as extensions via applications.
If things don’t look exactly the same, don’t worry. In every new version of XP the background picture gets updated. Also, admin dashboard is automatically localized - based on your browsers preferred language. |
Task: Open Content Studio
Content Studio is the editorial interface used to create and manage content. It was pre-installed from Enonic Market as a part of the Essentials
template when you started the sandbox, and can now be accessed from the XP menu.
Click btn:[Content Studio] in the XP menu to launch it.
The first time your application was deployed to the sandbox, it automatically created a content project called Intro Project
and populated it with content. Since this is the only available project at the moment, Content Studio will automatically open it, revealing the list of sample content items.
The current project is shown at the top of Content Studio. |
Some of the content items will have a default preview. That’s okay for now - you’ll customize the preview later. |
Congrats on setting up the Enonic development environment
With the SDK running, lets have a look at the API.