Unofficial port of laravel's illuminate/view.

0.1.1 2016-08-16 18:14 UTC

This package is auto-updated.

Last update: 2020-05-18 03:52:21 UTC


This php library is an unofficial port of the laravel (L4) blade templating engine. See illuminate/blade and the docs for more details. The reason for this port is so that developers may consume it in a standalone project or another framework without being forced to import the whole laravel framework.

Requires PHP 5.4 or greater.

Includes a few extras:

  • Supports raw template string rendering.
  • Supports custom file extensions.
  • Cache path is optional.

Table of contents


This package can be installed by requiring it via composer.

$ composer require laraport/blade


If you have consumed blade views in laravel (which i am sure you have), its now a cinch to consume it in a standalone project as well.

The laravel way

The usual laravel way is setting the view path and cache.


require_once __DIR__ . '/vendor/autoload.php';

$path2views = __DIR__.'/path/to/views';
$path2cache = __DIR__.'/path/to/cache';

$Blade = new Laraport\Blade($path2views, $path2cache);

$View = $Blade->make('welcome', ['name' => 'Alice']);

echo $View->render();

which will render __DIR__./path/to/views/welcome{.blade}.php

Without cache

One of the added feature is loading a view without setting up a cache directory. This uses vfsStream behind the scenes.


require_once __DIR__ . '/vendor/autoload.php';

$Blade = new Laraport\Blade(__DIR__.'/path/to/views');

$View = $Blade->make('hello', ['name' => 'Bob']);

echo $View->render();

which will render __DIR__./path/to/views/hello{.blade}.php without any cache.

Raw string templates

Another added feature is supporting raw string template rendering. This also uses vfsStream behind the scenes.


require_once __DIR__ . '/vendor/autoload.php';

$View = Laraport\Blade::render('Hello {{ $name }}!', ['name' => 'Eve']);

echo $View->render();

which will print out Hello Eve!

Custom file extensions

You may also set custom file extensions for your blade view templates.


require_once __DIR__ . '/vendor/autoload.php';

$Blade = new Laraport\Blade(__DIR__.'/path/to/views');


$View = $Blade->make('custom', ['name' => 'Laravel']);

echo $View->render();

Which will render one of, custom.blade.php or custom.php, whichever is found.

You may add more than one extension if you so wish.

Shared data

Data may also be shared as globals for all your views.


require_once __DIR__ . '/vendor/autoload.php';

$Blade = new Laraport\Blade(__DIR__.'/path/to/views');

$Blade->share('acme', 'baz');

$View = $Blade->make('foo');

echo $View->render();

$acme will be available to all views.


First make sure you are in the project source directory.

Do a composer install.

$ composer install

Run the tests.

$ vendor/bin/phpunit


$ composer test

Similar projects


Copyright (c) Kamal Khan. Released under the MIT License.