Setting up your development environment
Before we can start building, let’s make sure we have the right tools available to start developing efficiently with XP. In general, they are:
Basic command line (a.k.a terminal) knowledge → executing commands through text
Enonic CLI → managing your XP projects
Git and Github → versioning your XP projects
Integrated Development Environment → coding your ideas into XP projects
If you’ve already got those configured and installed, feel free to skip to the next chapter.
The command line 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.
If you are insecure about basic terminal knowledge, we recommend the following introductory guides (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.
Enonic provides a Command Line Interface (CLI) for working with XP.
If the concept of CLI is new to you, you can imagine it as an interactive terminal program that will listen for some specific inputs (usually as text), and based on them, execute specific tasks on your machine.
The goal of the CLI is to improve the development workflow, and, by using it, you’ll have an easy and quick way to manage your XP apps.
The easiest and fastest way to install the CLI is by using Node Package Manager (NPM):
npm install -g @enonic/cli
Note that to run the npm install command you need to make sure that you have both Node and NPM installed on your machine. You can quickly check if they are installed by running the following commands on your terminal:
to check the version of Node you have installed locally. Same for NPM:
If they are not installed, you can head to nodejs.org to proceed installing them.
After running the installation command above, you can check if the Enonic CLI was properly installed by running
Let’s first list some commands… run the following command in your terminal:
It should output something that looks a bit like this:
Enonic CLI 2.6.1 Manage XP instances, home folders and projects USAGE: enonic [global options] [command] [command options] [arguments...] COMMANDS: create Create a new Enonic project snapshot Create and restore snapshots dump Dump and load complete repositories export Export data from a given repository, branch and content path. import Import data from a named export. app Install, stop and start applications repo Tune and manage repositories cms CMS commands system System commands auditlog Manage audit log repository latest Check for latest version upgrade Upgrade to the latest version uninstall Uninstall Enonic CLI vacuum Removes old version history and segments from content storage help, h Shows a list of commands or help for one command CLOUD COMMANDS: cloud Manage Enonic cloud PROJECT COMMANDS: sandbox Manage Enonic instances project Manage Enonic projects GLOBAL OPTIONS: --help, -h show help --version, -v print the version
If you want to know more about how to use one of the subcommands, you can use the
help subcommand. For instance, if you want to know more about the
sandbox subcommand, you can run:
enonic sandbox help
NAME: enonic sandbox - Manage Enonic instances USAGE: enonic sandbox [global options] command [command options] [arguments...] VERSION: 2.6.1 COMMANDS: list, ls List all sandboxes start Start the sandbox. stop Stop the sandbox started in detached mode. create Create a new sandbox. delete, del, rm Delete a sandbox upgrade, up Upgrades the distribution version. GLOBAL OPTIONS: --help, -h show help
As can be seen, there are a lot of commands and their subcommands to help you. On this guide, we’ll only cover the necessary ones to be able to start developing on XP.
|Consider checking the CLI documentation to further investigate its capabilities.|
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.|
To install Git, follow the notes for your operating system below.
|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
To install Git using Scoop, run the following command from Powershell:
scoop install git
To install Git with Snapcraft, run the following command:
sudo snap install git
Once you have installed Git, you can verify that it’s working correctly by running the following command:
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.
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 their download page and install the version matching your operating system.
If you opt to move forward with VS code as your IDE, its worth checking some of the powerful extensions available on their marketplace.
Congrats! You’ve installed the Enonic CLI, Git, and an IDE. 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.