PHPackages                             fiskhandlarn/blade - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. fiskhandlarn/blade

ActiveLibrary[Templating &amp; Views](/categories/templating)

fiskhandlarn/blade
==================

A library for using Laravel Blade templates in WordPress/WordPlate.

v0.6.2(3y ago)365.8k5[5 issues](https://github.com/fiskhandlarn/blade/issues)GPL-3.0-or-laterPHPPHP ^7.3 || ^8.0CI failing

Since Apr 20Pushed 3y ago3 watchersCompare

[ Source](https://github.com/fiskhandlarn/blade)[ Packagist](https://packagist.org/packages/fiskhandlarn/blade)[ RSS](/packages/fiskhandlarn-blade/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (13)Used By (0)

blade
=====

[](#blade)

[![blade](logo.svg)](logo.svg)

A library for using [Laravel Blade](https://laravel.com/docs/8.x/blade) templates in WordPress/[WordPlate](https://github.com/wordplate/wordplate).

[![Build Status](https://camo.githubusercontent.com/36c164a289a98c72264af70da069e2d0f476035c71564cf035f0757f71df8e37/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f6669736b68616e646c61726e2f626c6164653f6c6162656c3d6275696c642669636f6e3d676974687562)](https://github.com/fiskhandlarn/blade/actions)[![Coverage Status](https://camo.githubusercontent.com/bac87a88d8d433a7cd969b29dad3cc9080d15e9100f6c06356f12a262bea9c16/68747470733a2f2f62616467656e2e6e65742f636f6465636f762f632f6769746875622f6669736b68616e646c61726e2f626c616465)](https://codecov.io/github/fiskhandlarn/blade)[![Total Downloads](https://camo.githubusercontent.com/b6fe14044c7f9d412aaf8469667b9475da6d29999dec1d2321915edf3257e637/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f6669736b68616e646c61726e2f626c616465)](https://packagist.org/packages/fiskhandlarn/blade)[![Latest Version](https://camo.githubusercontent.com/38465686e49806937f39c6fed6c336e62f46a5e77cc5899f43b5f8495db04396/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f6669736b68616e646c61726e2f626c616465)](https://packagist.org/packages/fiskhandlarn/blade)[![License](https://camo.githubusercontent.com/2871d9c5c104f9562eb96b8c29b7c4cfc634e04451113101b8647321cae7180a/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f6c6963656e73652f6669736b68616e646c61726e2f626c616465)](https://packagist.org/packages/fiskhandlarn/blade)

Installation
------------

[](#installation)

Require this package, with [Composer](https://getcomposer.org), in the root directory of your project.

```
$ composer require fiskhandlarn/blade
```

Usage
-----

[](#usage)

### Render

[](#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

[](#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`](./src/BladeController.php).

... 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](https://github.com/soberwp/controller) for more info on how to use controllers.

Supported features:

- [Basic Controller](https://github.com/soberwp/controller#basic-controller)
- [Using Components](https://github.com/soberwp/controller#using-components)
- [Advanced Custom Fields Module](https://github.com/soberwp/controller#advanced-custom-fields-module)
- [Lifecycles](https://github.com/soberwp/controller#lifecycles)
- [Disable Option](https://github.com/soberwp/controller#disable-option)

Unsupported features:

- [Creating Global Properties](https://github.com/soberwp/controller#creating-global-properties)
- [Blade Debugger](https://github.com/soberwp/controller#blade-debugger)

Untested features:

- [Inheriting the Tree/Hierarchy](https://github.com/soberwp/controller#inheriting-the-treehierarchy)

Unnecessary features:

- [Using Functions](https://github.com/soberwp/controller#using-functions) (this can be achieved with vanilla PHP)
- [Template Override Option](https://github.com/soberwp/controller#template-override-option)

### Custom directive

[](#custom-directive)

Create a custom [directive](https://laravel.com/docs/8.x/blade#extending-blade) with helper function `blade_directive`:

```
blade_directive('datetime', function ($expression) {
    return "";
});
```

... or use the `directive` method on a `Blade` object:

```
$blade->directive('datetime', function ($expression) {
    return "";
});
```

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

[](#custom-composer)

Create a custom [composer](https://laravel.com/docs/8.x/views#view-composers) 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)

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

[](#extension)

The `Blade` class passes all method calls to the internal compiler (see [documentation](https://laravel.com/docs/8.x/blade)) or view factory (see [documentation](https://laravel.com/docs/8.x/views) for info on `exists`, `first` and `creator`).

Cache
-----

[](#cache)

If `WP_DEBUG` is set to `true` templates will always be rendered and updated.

Multisite
---------

[](#multisite)

If run on a WordPress Multisite the cached files will be separated in subfolders by each site's blog id.

Filters
-------

[](#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
-------

[](#license)

[GNU GPL 3.0+](//www.gnu.org/copyleft/gpl.html "GNU GPL 3.0")

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 93.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~154 days

Recently: every ~281 days

Total

11

Last Release

1402d ago

PHP version history (3 changes)v0.1PHP ^7.1.3

v0.2PHP ^7.2

v0.6.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/680264?v=4)[fiskhandlarn](/maintainers/fiskhandlarn)[@fiskhandlarn](https://github.com/fiskhandlarn)

---

Top Contributors

[![fiskhandlarn](https://avatars.githubusercontent.com/u/680264?v=4)](https://github.com/fiskhandlarn "fiskhandlarn (46 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (3 commits)")

---

Tags

bladeblade-templatelaravelrendertemplateviewwordplatewordpresswordpress-php-librarylaravelwordpressbladetemplateviewrenderwordplate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fiskhandlarn-blade/health.svg)

```
[![Health](https://phpackages.com/badges/fiskhandlarn-blade/health.svg)](https://phpackages.com/packages/fiskhandlarn-blade)
```

###  Alternatives

[jenssegers/blade

The standalone version of Laravel's Blade templating engine for use outside of Laravel.

8661.2M109](/packages/jenssegers-blade)[leitsch/kirby-blade

Enable Laravel Blade Template Engine for Kirby 4 and Kirby 5

219.2k](/packages/leitsch-kirby-blade)[johnturingan/laravel-fly-view

Render Blade templates from string mark-up.

163.9k](/packages/johnturingan-laravel-fly-view)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
