Create your project

No matter PHP or nodejs, you should create a project first. The project definition file provides dependency information, and help you to install required packages by package management tools. Here are examples of project definition file with minimal settings, you may use it as a quick start. You can modify the file to fit your project later.

Create project definition file

PHP

file name: composer.json

Source Code
{
  "name": "zordius/HandlebarsCookbook",
  "description": "A cookbook of handlebars and mustache, focus on handlebars.js , mustache.js and lightncandy usage",
  "homepage": "https://github.com/zordius/HandlebarsCookbook",
  "require": {
    "php": ">=5.4.0"
  },
  "require-dev": {
    "zordius/lightncandy": "1.2.6"
  }
}

nodejs

file name: package.json

Source Code
{
  "name": "handlebars.cookbook",
  "version": "0.0.1",
  "description": "A cookbook of handlebars and mustache, focus on handlebars.js , mustache.js and lightncandy usage",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/zordius/HandlebarsCookbook.git"
  },
  "homepage": "https://github.com/zordius/HandlebarsCookbook",
  "devDependencies": {
    "handlebars": "4.7.7",
    "mustache": "4.2.0"
  }
}

Install dependency

PHP

composer install

nodejs

npm install

Require the library

lightncandy

require('./vendor/autoload.php');
use LightnCandy\LightnCandy;

handlebars.js

var Handlebars = require('handlebars');

mustache

var Mustache = require('mustache');

Start to use the library

Now the library is ready to go!