This package is abandoned and no longer maintained. No replacement package was suggested.

Use Laravel Blade in any PHP project.

3.0.0 2020-12-17 14:44 UTC

This package is auto-updated.

Last update: 2023-03-14 08:56:05 UTC


README

Tests Latest Stable Version Total Downloads

Blade

Use Laravel Blade in any PHP project. The adapter class is clean and I don't make use of unecessary Laravel related dependencies.

If you don't know about Blade yet, please refer to the official documentation.

Installation

composer require benjamincrozat/blade

Usage

This package allows you to do almost everything you were able to do in a Laravel project.

Here is a basic view rendering:

use BC\Blade\Blade;

$blade = new Blade('views', 'cache');

echo $blade->make('home')
    ->withFoo('bar')
    ->render();

Add the @hello('John') directive:

$blade->directive('hello', function ($expression) {
    $expression = trim($expression, '\'"');

    return "<?php echo 'Hello $expression!'; ?>";
});

Make a variable available in all views thanks to view composers:

$blade->composer('*', fn ($view) => $view->withFoo('bar'));

... and so on. Just use Blade as you are used to.

Enjoy!

License

WTFPL