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.

  1. Install the CLI - Follow the installation instructions for your operating system.

  2. Verify the installation - Run enonic -v in your terminal. It prints the installed CLI version.

Task: Create and start a sandbox

  1. 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
    -f forces the use of default values for the remaining options, and starts the sandbox.
  2. 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.

  1. Create a new project - Use the Introduction app as a starter by running this command:

    enonic project create com.example.tutorial.nextjs -r tutorial-intro -s tutorial_nextjs -d tutorial-nextjs-enonic -f

    This command will:

    • use the GitHub repo github.com/enonic/tutorial-intro as a starter

    • create an app called com.example.tutorial.nextjs

    • link it to the tutorial_nextjs sandbox

    • place the project in a new folder called tutorial-nextjs-enonic

  2. Deploy the application - Run these commands to build and run your application:

    cd tutorial-nextjs-enonic
    enonic dev

    The last command builds and deploys the app to the sandbox, then watches the code for changes and rebuilds as you work on it.

  3. Verify the deployment - In dev mode 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.

  1. Open the Welcome page - Go to http://localhost:8080 in your browser.

    The XP boot page
    Figure 1. Welcome page

    The Welcome page provides an overview of the sandbox, including installed applications and standard configuration files. Intro should be in the list, together with the other applications that were installed when you created the sandbox.

  2. Log in - Click Log In as Guest to open the XP admin dashboard.

    The XP admin dashboard
    Figure 2. The XP admin dashboard

    The 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.

  1. 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 (id intro) 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.
  2. Verify the sample content - Content Studio lists the sample content items:

    Movie DB in Content Studio
    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.


Contents

Contents