Skip to content

Setting Up Your Development Environment

Imran Hossain edited this page Feb 25, 2022 · 4 revisions

This page will guide you through the process of setting up Sensei LMS development environment on your local machine. It should work on Linux, macOS, or Windows Subsystem for Linux on Windows 10.

Table of Contents

Pre-requisites

Before starting, make sure you have the following software installed and working on your machine:

  1. Git to clone the Sensei LMS repository (or your fork of the Sensei LMS repository).
  2. Node.js (version == 16) and NPM to install Node packages used to build assets and other tasks.
  3. Composer to install PHP packages required by Sensei LMS such as the sensei-rest-api and the jetpack-autoloader. It's also necessary to use the PHP CodeSniffer that ensures your code follows code standards.
  4. WP-CLI for updating i18n pot files.

Configure a local WordPress instance

For this guide we will use VVV, which is a local WordPress development environment built using Vagrant and VirtualBox, to run a local WordPress instance and install Sensei LMS on top of it. But it is worth noting that it is possible to set up a Sensei LMS development environment using several other stacks (docker, LAMP, etc). If you opt to use a solution other than VVV, you can skip to the next section. Keep in mind that you might need to make some small adjustments to the steps in the rest of this guide.

To configure our local WordPress instance, you will need to:

  1. Install VirtualBox
  2. Install vagrant
  3. Install and provision VVV
  4. If everything worked as expected, you should have a WordPress installation running on the following URL: https://one.wordpress.test. This is the WP site that we will use to install Sensei LMS.

Clone Sensei LMS repository

To install Sensei LMS on your WordPress installation, you need to decide whether you will clone the Sensei LMS repository directly or your Sensei LMS fork. If you plan to contribute to Sensei LMS code base, it is recommended that you clone your fork. If needed, see this GitHub document on how to create a fork.

In your terminal:

  1. Go to the WordPress plugins directory:
    $ cd ~/vvv-local/www/wordpress-one/public_html/wp-content/plugins/
    
  2. Clone the repository:
    • If cloning Sensei LMS repository:
    $ git clone git@github.com:Automattic/sensei.git
    
    • If cloning your own fork replace USER_NAME with your GitHub username:
    $ git clone git@github.com:USER_NAME/sensei.git
    

Install dependencies and generate assets

To install Sensei LMS dependencies (this includes some functionality that installs git pre-commit hooks for code style checks and Grunt that is used to generated minified versions of the SCSS and JS files):

$ cd ~/vvv-local/www/wordpress-one/public_html/wp-content/plugins/sensei
$ npm install
$ composer install

To generate JS and CSS assets run the following command from the Sensei LMS root directory:

npm run build:assets

To automatically rebuild the assets whenever a JS or SCSS file is modified run:

npm run start

IDE integrations

Sensei LMS core has linting rules in place via pre-commit hooks to ensure code standards are used. Ensure you have installed NPM and Composer packages, so these are set up!

While developing, we recommend adding support to your editor for the following (most IDEs have plugins for this):

Additional resources

Running unit tests