Setting up your development environment

Contents

Before we can start building apps and APIs, let’s make sure we have the right tools available to work efficiently with XP. This chapter walks you through installing the fundamental tools we will be using throughout this guide, including a text editor, a package manager for your system, Git, and the Enonic CLI. If you’ve already got these installed, feel free to skip to the next chapter (or to the relevant sections if you’re missing some of them).

The command line

The command line — aka the terminal — is a powerful, text-based interface for running commands on your computer. You can also use the terminal to navigate your file system, similar to macOS’ Finder or Windows’ Explorer. The program running in the terminal (that interprets your commands) is known as a shell.

The rest of this chapter will focus primarily on working with the command line, so go ahead and open your favorite terminal. If you don’t know how to open a terminal on your system, don’t worry! Instead, check out the guide for macOS, Windows, or Linux (depending on your operating system).

When we ask you to "run a command" later on in this document, you can assume that we’re asking you to run it in a terminal unless otherwise specified.

To run a command in your terminal, type in the command and press enter. For instance, the command cd myfolder would change the shell’s working directory to the myfolder directory, assuming that it exists.

Package managers

Enonic provides a command line interface (CLI) for working with XP. To make it easy to install and keep it updated, we distribute it via a number of package managers. Package managers are terminal-based "app stores" that focus on developer and command line tools.

Find the section below for your operating system to see what package managers we support and how to install them.

macOS: Homebrew

For macOS, we distribute the Enonic CLI through the popular package manager Homebrew. Homebrew lets you install, uninstall, and manage your command line tools, including updating them when new versions are made available.

To install Homebrew, follow the instructions in the link above or run the following command:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once installed, run the following command in your terminal to verify that everything is working:

brew help

Windows: Scoop

We use the Scoop package manager for Windows. To install Scoop, visit their website, or simply run these two commands from Powershell:

To launch Powershell from your regular terminal, the Command Prompt, simply execute the command powershell. The prompt should then start with PS.
set-executionpolicy remotesigned -scope currentuser
iwr -useb get.scoop.sh | iex

To verify that Scoop was installed successfully, run the following command:

scoop help

Linux: Snapcraft

We use Snapcraft to distribute packages for Linux. Snapcraft comes preinstalled on a number of popular Linux distributions, including Ubuntu and Manjaro, and is also available for most other major Linux distributions, such as Debian, elementary OS, and Pop!_OS.

Specific instructions will vary according to your distribution, so be sure to consult the snapd installation instructions for your particular distro.

To verify that it’s installed and available, run the following command in your terminal. It should print out your version of Snap.

snap version

The Enonic CLI

Now, we’ll install the Enonic CLI via the package manager we just set up. The CLI provides a number of enonic-specific commands designed to make working with XP fast, easy, and efficient.

While we heavily recommend using a package manager, you can also download and install the executables manually if you prefer. To do that, visit the the Enonic CLI public repo, download the files that correspond to the desired CLI version and your OS, and install them as you would any other binary files on your system. There is also a Windows installer for the CLI available.

Installation

The steps differ depending on your OS. Follow the steps below that best match your OS.

macOS

From your terminal:

  1. Make the enonic/cli repository via Homebrew’s tap functionality

    brew tap enonic/cli
  2. Install the CLI

    brew install enonic

To upgrade to newer versions of enonic CLI when they become available, run the command brew upgrade enonic

Windows

From a Powershell terminal:

  1. Make the CLI bucket available to install

    scoop bucket add enonic https://github.com/enonic/cli-scoop
  2. Install the CLI

    scoop install enonic

To upgrade to newer versions of enonic CLI when they become available, run the command scoop update enonic

Linux

From your terminal, run the following command:

sudo snap install enonic

Snap automatically keeps your snaps updated. To manually force an update, run the command sudo snap refresh enonic

Verification

When you have installed the CLI, verify that it’s working by running

enonic version

Git

Git is a free and open source distributed version control system. Later on in this tutorial, we will create new Enonic development projects using starters. The Enonic CLI uses Git to download these starters and to prepare the files for your project locally.

Want to learn more about Git? Check out this useful Git handbook by Github.

Installation

To install Git, follow the notes for your operating system below.

macOS

Apple maintains its own fork of Git. If you have XCode installed, you already have Git installed too.

To install Git via Homebrew, run this command:

brew install git

Windows

To install Git using Scoop, run the following command from Powershell:

scoop install git

Linux

To install Git with Snapcraft, run the following command:

sudo snap install git

Verification

Once you have installed Git, you can verify that it’s working correctly by running the following command:

git version

Source-code editors

Source-code editors (also known as text editors or just editors for short) are applications designed primarily for editing plain text and often specifically for working with code. They are therefore commonly used for programming.

If you do not yet have an editor you like, follow the steps below to get started with one.

Download Visual Studio Code

Visual Studio Code (often shortened to VS Code or simply Code) is one of the most popular source-code editors around at the moment. It’s free, open source, and available on all major platforms.

You can navigate to the download page and download and install the version matching your operating system. Alternatively, if you’re getting into this whole package manager business, it’s also available in all package managers listed above. The install instructions will vary, though, so you’ll have to figure that out on your own.

Install Prettier

While not mandatory, we also recommend you install the "Prettier - Code formatter" plugin to help keep your code nicely formatted. It helps to keep your code easier to read.

Follow these steps to install the VS Code plugin:

  1. Open the VS Code extensions panel (View ⇒ Extensions).

  2. Search for: “Prettier - Code formatter”.

  3. Click “Install”.

When the installation is finished, you must restart VS Code to activate the Prettier.

Summary

Congrats! You’ve installed a package manager, Git, the Enonic CLI and a text editor. You’re now set up to start working with Enonic XP 🚀

Keep your new tools at hand; we’ll be using them heavily throughout this guide, so you’ll have lots of time to get to know them better.

Contents