fiskhandlarn/blade
Larablocks Analysis
fiskhandlarn/blade works with Laravel 8 (latest release v0.6.2, Jul 14, 2022), which reached end of life on Jan 24, 2023: no more fixes, even for security.
Laravel 5 and 7 in earlier releases.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- Supports only Laravel 8, past end of life since Jan 24, 2023
- No release in the last 12 months (last: Jul 14, 2022)
- 67 downloads a month (needs 10,000)
- 35 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Jul 14, 2022.
- No releases in the last 12 months.
- First released: Apr 20, 2018.
- Monthly downloads: 67, up 40% from six months ago.
- 5 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.
| Install | |
|---|---|
composer require fiskhandlarn/blade |
|
| Latest Version: | v0.6.2 |
| PHP: | ^7.3 || ^8.0 |
| Laravel: | 8 |
| Older releases: | 5 · 7 |
| License: | GPL-3.0-or-later |
| Last Updated: | Jul 14, 2022 |
| Links: | GitHub · Packagist |
blade
A library for using Laravel Blade templates in WordPress/WordPlate.
Installation
Require this package, with Composer, in the root directory of your project.
$ composer require fiskhandlarn/blade
Usage
Render
Use helper function blade:
blade('index', ['machine' => 'Voight-Kampff']);
(This renders and echoes the template /resources/views/index.blade.php and caches it to /storage/views.)
... or instantiate Blade by passing the folder(s) where your view files are located, and a cache folder. Render a template by calling the render method.
use Fiskhandlarn\Blade;
$blade = new Blade(get_stylesheet_directory() . '/views', get_stylesheet_directory() . '/cache');
echo $blade->render('index', ['machine' => 'Voight-Kampff']);
Render with data from a controller class
Use helper function blade_controller:
blade_controller('index', 'Index');
(This renders and echoes the template /resources/views/index.blade.php with data generated from App\Controllers\Index.)
Controller classes must extend Fiskhandlarn\BladeController.
... or use the renderController method on a Blade object:
echo $blade->renderController('index', 'Index');
You can also pass additional data (this won't override properties from the controller though):
blade_controller('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);
echo $blade->renderController('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);
See soberwp/controller for more info on how to use controllers.
Supported features:
Unsupported features:
Untested features:
Unnecessary features:
- Using Functions (this can be achieved with vanilla PHP)
- Template Override Option
Custom directive
Create a custom directive with helper function blade_directive:
blade_directive('datetime', function ($expression) {
return "<?php echo with({$expression})->format('Y-m-d H:i:s'); ?>";
});
... or use the directive method on a Blade object:
$blade->directive('datetime', function ($expression) {
return "<?php echo with({$expression})->format('Y-m-d H:i:s'); ?>";
});
Then you can use the directive in your templates:
{{-- In your Blade template --}}
@php $dateObj = new DateTime('2019-11-01 00:02:42') @endphp
@datetime($dateObj)
Custom composer
Create a custom composer with helper function blade_composer:
// Make variable available in all views
blade_composer('*', function ($view) {
$view->with(['badge' => 'B26354']);
});
... or use the composer method on a Blade object:
// Make variable available in all views
$blade->composer('*', function ($view) {
$view->with(['badge' => 'B26354']);
});
Share variables
Share variables across all templates with helper function blade_share:
// Make variable available in all views
blade_share(['badge' => 'B26354']);
... or use the share method on a Blade object:
$blade->share(['badge' => 'B26354']);
Extension
The Blade class passes all method calls to the internal compiler (see documentation) or view factory (see documentation for info on exists, first and creator).
Cache
If WP_DEBUG is set to true templates will always be rendered and updated.
Multisite
If run on a WordPress Multisite the cached files will be separated in subfolders by each site's blog id.
Filters
Use the blade/view/paths filter to customize the base paths where your templates are stored. (Default value is /resources/views.)
add_filter('blade/view/paths', function ($paths) {
$paths = (array) $paths;
$paths[] = get_stylesheet_directory() . '/views';
return $paths;
});
Use the blade/cache/path filter to customize the cache folder path. (Default value is /storage/views.)
add_filter('blade/cache/path', function ($path) {
$uploadDir = wp_upload_dir();
return $uploadDir['basedir'] . '/.bladecache/';
});
Use the blade/cache/path filter to control creation of cache folder. (Default value is true.)
add_filter('blade/cache/create', '__return_false');
Use the blade/controller/namespace filter to customize the controller namespace. (Default value is App\Controllers.)
add_filter('blade/controller/namespace', function () {
return 'MyApp\Controllers';
});
License
Alternatives to fiskhandlarn/blade
The standalone version Blade Template Engine from Laravel in a single php file
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.6.2 | ^7.3 || | ^8.83 | GPL-3.0-or-later | |
| v0.6.1 | ^7.3 || | ^8.42 | GPL-3.0-or-later | |
| v0.6.0 | ^7.3 || | ^8.32 | GPL-3.0-or-later | |
| v0.5.0 | ^7.2 | ^7.10 | MIT | |
| v0.4.2 | ^7.2 | ^5.7 | MIT | |
| v0.4.1 | ^7.2 | ^5.7 | MIT | |
| v0.4 | ^7.2 | ^5.7 | MIT | |
| v0.3 | ^7.2 | ^5.7 | MIT | |
| v0.2.1 | ^7.2 | ^5.7 | MIT | |
| v0.2 | ^7.2 | ^5.7 | MIT | |
| v0.1 | ^7.1.3 | MIT |