Download the PHP package proai/laravel-handlebars without Composer

On this page you can find all versions of the php package proai/laravel-handlebars. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-handlebars

Laravel Handlebars

Latest Stable Version Total Downloads Latest Unstable Version License

This package allows you to use Handlebars (and Mustache) templates with Laravel. You can integrate Handlebars templates into Blade templates and you can even use the Blade language directives @lang and @choice in Handlebars templates.

It's the perfect choice, if you want to use the same templates in different languages (i. e. PHP and JavaScript) and/or server- and clientside. The compiling and rendering is veeery fast, because this package wraps the super fast template engine LightnCandy.

Installation

Laravel Handlebars is distributed as a composer package. So you first have to add the package to your composer.json file:

Then you have to run composer update to install the package. Once this is completed, you have to add the service provider to the providers array in config/app.php:

You can publish the package configuration with the following command:

Usage

Configuration

Most of the options in config/handlebars.php are also used by LightnCandy. So please have a look at the LightnCandy readme for more information.

Only the basedir option can't be set in this config file. Instead the package uses the paths option in config/view.php to define base directories and also the compiled option in the same file to define the directory for the compiled templates (i. e. the cache directory).

In addition to the LightnCandy options there are the options language_helpers, optional_raw_output and translate_raw_output. These options are described below.

Basics

You can use Handlebars templates the same way you use Blade templates. You can return them with View::make('articles', ['name' => 'Taylor']) or include them with the Blade @include directive, i. e. @include('articles', ['name' => 'Taylor']).

By default all views which have a .hbs or .handlebars file extension are automatically detected as Handlebars templates. You can add more file extensions that should be treated as Handlebars templates in the fileext array in config/handlebars.php.

Language Helpers

If you wish, you can use the Blade language directives @lang and @choice in Handlebars templates, too. You have to set $language_helpers = true in order to use them. Here is an example:

Raw Output

This feature is currently broken. If you want to use it, use v1.1 or below or help to fix it!

If you want to output the raw code of a template (maybe because you want to use the unrendered template clientside), you can set $optional_raw_output = true in the configuration. Then you can pass a variable $raw = true to the template or more comfortable you can use the @raw Blade directive.

If you want to output a raw template with compiled and rendered language variables, you can set $translate_raw_output = true.

Partials

This package automatically adds the directory of the current template to the basedir of LightnCandy. By that it is possible to easily include other Handlebars templates in the same directory. Just write {{> comment}} to include comment.hbs from the same directory.

Example Template

For more information about the Handlebars syntax see the Handlebars documentation. It does not matter that the examples are for JavaScript, because Handlebars templates are the same for JavaScript and PHP.

Using it with Webpack

If you want to use this package client side with webpack, have a look at this article:

Sharing templates between PHP and JavaScript in Laravel

Support

Bugs and feature requests are tracked on GitHub.

License

This package is released under the MIT License.


All versions of laravel-handlebars with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
illuminate/view Version ^6.0|^7.0|^8.0|^9.0|^10.0
zordius/lightncandy Version 1.2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package proai/laravel-handlebars contains the following files

Loading the files please wait ....