Setting up Enonic
Contents
In this chapter you will create a local Enonic development environment, then create and deploy an Enonic app with sample content.
Task: Install the Enonic CLI
The Enonic CLI manages local instances of Enonic XP, known as sandboxes, and builds and deploys your apps.
-
Install the CLI - Follow the installation instructions for your operating system.
-
Verify the installation - Run
enonic -vin your terminal. It prints the installed CLI version.
Task: Create and start a sandbox
-
Create a sandbox - Run this command in your terminal to create a sandbox called
tutorial_nextjs. It works from any folder:enonic sandbox create tutorial_nextjs -t essentials -v 8.1.3 -f-fforces the use of default values for the remaining options, and starts the sandbox. -
Verify that the sandbox is running - Open http://localhost:8080 in your browser. The Enonic XP Welcome page appears.
Leave the sandbox running in this terminal window. To stop it, press ctrl-c. To start it again, run enonic sandbox start tutorial_nextjs from any folder.
| The sandbox has its own content and applications, separate from other tutorials. All sandboxes use the same ports by default, so stop the sandbox of any other tutorial before starting this one. |
Task: Create and deploy your app
Open a new terminal window in the folder where you keep your tutorial projects, for example enonic-tutorials/. The commands below create the app in a subfolder of its own.
-
Create a new project - Use the
Introductionapp as a starter by running this command:enonic project create com.example.tutorial.nextjs -r tutorial-intro -s tutorial_nextjs -d tutorial-nextjs-enonic -fThis command will:
-
use the GitHub repo
github.com/enonic/tutorial-introas a starter -
create an app called
com.example.tutorial.nextjs -
link it to the
tutorial_nextjssandbox -
place the project in a new folder called
tutorial-nextjs-enonic
-
-
Deploy the application - Run these commands to build and run your application:
cd tutorial-nextjs-enonic enonic devThe last command builds and deploys the app to the sandbox, then watches the code for changes and rebuilds as you work on it.
-
Verify the deployment - In
devmode the CLI keeps watching for changes, so the build process never exits. This is expected behavior. When your terminal shows output like the following, the app has been built and deployed:[server] CLI Watching for changes in "." [server] CLI Ignoring changes in "**/{.git,node_modules}/**" | "build/resources/main" [browserSync] [Browsersync] Reloading Browsers... (buffered 9 events) <============-> 94% EXECUTING [17m 31s] > :dev
Leave enonic dev running in this terminal window as well. To stop it, press ctrl-c. To resume the tutorial later, start the sandbox and then run enonic dev from the tutorial-nextjs-enonic folder again.
Task: Open the admin dashboard
The sandbox has a web interface for managing applications and content.
-
Open the Welcome page - Go to http://localhost:8080 in your browser.
Figure 1. Welcome pageThe Welcome page provides an overview of the sandbox, including installed applications and standard configuration files.
Introshould be in the list, together with the other applications that were installed when you created the sandbox. -
Log in - Click Log In as Guest to open the XP admin dashboard.
Figure 2. The XP admin dashboardThe center menu, known as the
XP menu, lets you navigate between admin tools. Applications can add admin tools as extensions.If things don’t look exactly the same, don’t worry. In every new version of XP the background picture gets updated. Also, the admin dashboard is automatically localized, based on your browser’s 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 be accessed from the XP menu.
-
Launch Content Studio - Click Content Studio in the XP menu.
The first time your application was deployed to the sandbox, it automatically created a content project called
Intro Project(idintro) and populated it with content. Since this is the only available project at the moment, Content Studio opens it automatically.The current project is shown at the top of Content Studio. -
Verify the sample content - Content Studio lists the sample content items:
Some of the content items will have a default preview. That’s okay for now - you’ll customize the preview later.
Summary
You’ve installed the Enonic CLI, started the tutorial_nextjs sandbox, deployed the com.example.tutorial.nextjs app based on the Intro starter, and opened its sample content in Content Studio.
Next, you’ll query that content with the GraphQL API.