This is a standalone blade template engine for PHP. It is a simple and easy to use template engine that is designed to be used in any PHP project.
You can install this package via composer using this command:
composer require binjuhor/blade
use Binjuhor\Blade\BladeTemplate;
$template = new BladeTemplate([
'views' => 'path/to/views/folder',
'cache' => 'path/to/cache/folder',
'compileDir' => 'path/to/compiled/folder',
'url' => 'http://your-app-url.test'
]);
echo $template->render('view', ['data' => 'value']);
Read more about the blade template engine here.
You can use the compile
method to compile blade templates. For example, if you have a blade template called home.blade.php
and you want to compile it, you can do so by calling the compile
method.
$template->compile();
require_once "vendor/autoload.php";
use Binjuhor\Blade\BladeTemplate as Blade;
$compileDir = __DIR__ . '/compiles';
$viewDirectory = __DIR__ . '/resources/views';
$cacheDirectory = __DIR__ . '/cache';
$page = isset($_REQUEST['f']) ? $_REQUEST['f'] : 'index';
$blade = new Blade([
'view' => $viewDirectory,
'cache' => $cacheDirectory,
'compileDir' => $compileDir,
'url' => 'http://html-generator.test'
]);
echo $blade->render($page);
$blade->compiles();
./index.php
./cache
./compiles
./resources
/assets
/css
/js
/images
/views
about.blade.php
contact.blade.php
home.blade.php
404.blade.php
/partials
header.blade.php
footer.blade.php
sidebar.blade.php
Check out the example directory for a complete example.
The MIT License (MIT). Please see License File for more information.
- Blade template engine by Taylor Otwell
- This package is created by Binjuhor