Using Jens Segers’ Blade package to render Blade templates in a standalone PHP application.

Installation

composer require jenssegers/blade

Usage

use Jenssegers\Blade\Blade;

// Settings
$viewPath  = __DIR__ . '/views';
$cachePath = __DIR__ . '/tmp/view-cache';

// Create cache directory (or do this manually)
if (!@mkdir($cachePath, 0755, true) && !is_dir($cachePath)) {
    throw new RuntimeException("Directory '$cachePath' could not be created");
}

// Execute
$view = 'pages.index';
$data = ['pages' => $pages];

$blade = new Blade($viewPath, $cachePath);
$html = $blade->render($view, $data);

// Display
echo $html;