Skip to content
PHP bindings for handlebars.c
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci
examples
spec
tests Windows support and Appveyor (#52) Aug 9, 2017
.appveyor.yml
.editorconfig
.gitattributes
.gitignore
.gitmodules
.travis.sh
.travis.yml
CHANGELOG.md
LICENSE.md Update license text so GitHub can detect it Jul 1, 2017
README.md
compiler.c
config.m4
config.w32
default.nix
derivation.nix PHP 8 compat, remove PHP 5 support May 26, 2019
exceptions.c PHP 8 compat, remove PHP 5 support May 26, 2019
generate-tests.php
handlebars.stub.php
impl.c
opcode.c
options.c
package.xml
parser.c
php_handlebars.c PHP 8 compat, remove PHP 5 support May 26, 2019
php_handlebars.h
program.c
registry.c
run-tests.win32.patch
safe_string.c
test_mem.sh
token.c
tokenizer.c
utils.c
value.c PHP 8 compat, remove PHP 5 support May 26, 2019
vm.c

README.md

php-handlebars

Build Status Build Status Coverage Status License

PHP bindings for handlebars.c. See also handlebars.php.

Installation

Nix / NixOS

nix-env -i -f https://github.com/jbboehr/php-handlebars/archive/master.tar.gz

with a custom version of PHP:

nix-env -i -f https://github.com/jbboehr/php-handlebars/archive/master.tar.gz --arg php '(import <nixpkgs> {}).php71'

or, in a .nix file:

(import <nixpkgs> {}).callPackage (import (fetchTarball {
  url = https://github.com/jbboehr/php-handlebars/archive/v0.8.3.tar.gz;
  sha256 = "17q3nv3b048bf873g12jzgnj11g4vzwww2rwcwfh7l46f34k3x8d";
})) {}

RPM repository

The extension is available in Remi's repository:

Fedora (change 24 to match your Fedora version)

dnf install https://rpms.remirepo.net/fedora/remi-release-24.rpm
dnf install --enablerepo=remi php-pecl-handlebars

RHEL/CentOS (for default PHP in base repository)

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install php-pecl-handlebars

Source

Install handlebars.c

Linux / OSX

Prerequisite packages are:

  • PHP development headers and tools
  • gcc >= 4.4 | clang >= 3.x | vc >= 11
  • GNU make >= 3.81
  • automake
  • autoconf
  • handlebars.c and all of its dependencies (talloc, json-c, libyaml)
  • (optional) php-psr

You will need the PHP development headers. If PHP was manually installed, these should be available by default. Otherwise, you will need to fetch them from a repository.

git clone https://github.com/jbboehr/php-handlebars.git
cd php-handlebars
phpize
./configure
make
make test
sudo make install

If you have specific PHP versions running:

git clone https://github.com/jbboehr/php-handlebars.git
cd php-handlebars
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make
make test
sudo make install

Add the extension to your php.ini:

echo extension=handlebars.so | tee -a /path/to/your/php.ini

Finally, restart the web server.

Usage

$vm = new Handlebars\VM();

echo $vm->render('{{foo}}', array('foo' => 'bar'));

echo $vm->renderFile('/path/to/foo.hbs', array('foo' => 'bar'));

See the examples folder for more examples.

License

This project is licensed under the Simplified BSD License (BSD-2-Clause).

You can’t perform that action at this time.