PHPackages                             jakewhiteley/bladezero - 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. jakewhiteley/bladezero

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

jakewhiteley/bladezero
======================

9.52.16(2y ago)14.0k1MITPHPPHP ^7.4|^8.0CI failing

Since Mar 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jakewhiteley/BladeZero)[ Packagist](https://packagist.org/packages/jakewhiteley/bladezero)[ RSS](/packages/jakewhiteley-bladezero/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (13)Versions (10)Used By (1)

BladeZero
=========

[](#bladezero)

Import Laravel's Blade templating engine into non-Laravel applications **the right way**.

### The wrong way

[](#the-wrong-way)

All other standalone versions of blade require ~16 dependencies, and run the `Iluminate/Container` and `Illuminate/View` packages in your app. This adds a ton of complexity to your app, and is [considered a bad idea](https://mattallan.org/posts/dont-use-illuminate-support/).

There are a few instances of packages rewriting the entire Blade engine from scratch, which creates the following typical issues:

- No longer able to rely on the [Laravel docs](https://laravel.com/docs/6.x/blade) means documentation is often incorrect.
- Features are often missing or implemented incorrectly.

### The \*right\* way

[](#the-right-way)

BladeZero is a direct split from `laravel/framework` and only includes files directly needed to compile Blade templates - no Container, no View, no fuss.

95% of the code is a perfect match for the code written by Taylor Otwell and the Laravel contributors, meaning every single Blade feature is supported exactly as it should be.

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

[](#installation)

Use [Composer](https://getcomposer.org/):

```
composer require jakewhiteley/bladezero
```

### Usage

[](#usage)

After pulling the package down, you need to provide the full paths to your templates and cache directories:

```
use Bladezero\Factory;

$templatesPath = realpath('./files');
$cachePath = realpath('./cache');

$blade = new Factory($templatesPath, $cachePath);

// Make and output a view with some data
echo $blade->make('example', ['title' => 'It Works!']);
```

### Extending BladeZero

[](#extending-bladezero)

As the `BladeZero\Factory` class is just a modifed `Illuminate\View\Factory`, all the methods you would expect are available:

```
// Add a new templates directory
$blade->addLocation(realpath('./shared/components'));

// Add a namespace
$blade->addNamespace('shared', realpath('./shared/components'));

// Register a component
$blade->component('components.alert', 'alert');

// Register a custom directive
$blade->directive('foo', function($expression) {
    return "";
});

// Register a custom if directive
$blade->if('foo', function($bar) {
    return $bar === 'foobar';
});

// Register a custom template alias
$blade->include('php.raw', 'foo');

// Add shared data
$blade->share($key, $value = null);
```

BladeZero supports all the Blade features you know such as [custom directives](https://laravel.com/docs/6.x/blade#extending-blade), [custom if statements](https://laravel.com/docs/6.x/blade#custom-if-statements), [components](https://laravel.com/docs/6.x/blade#components-and-slots).

BladeZero lets you write your own View classes as this package is to provide the Blade rendering engine for your own projects - not include half of Laravel. In order to facilitate this, some functionality you would access vie the `View` facade is also available; such as [making data available to all views](https://laravel.com/docs/6.x/views#passing-data-to-views), and view namespaces

Differences
-----------

[](#differences)

Even though the Blade compiler is 100% the same as it's Laravel twin, *your application is not*.

Because of this, BladeZero provides methods to easily get the Laravel-specific features of Blade working in your framework:

### @csrf

[](#csrf)

Use the `setCsrfHandler` method to specify how to provide the `@csrf()` directive with the correct token:

```
$blade->setCsrfHandler(function(): string {
    return MySessionClass::getUserToken();
});
```

### @auth

[](#auth)

Set how your application handles auth directives such as `@auth`, `@elseauth`, and `@guest`:

```
$blade->setAuthHandler(function(string $guard = null): bool {
    return MyUserClass::currentUserIs($guard);
});
```

### @can

[](#can)

Set how your application handles permissions directives such as `@can`, `@cannot`, and `@canany`:

```
$blade->setcanHandler(function($abilities, $arguments = []): bool {
    return MyUserClass::currentUserCan($abilities, $arguments);
});
```

### @inject

[](#inject)

If your application uses a [dependency injection Container](https://github.com/jakewhiteley/hodl), sepcify how services should be resolved via `@inject`:

```
$blade->setInjectHandler(function(string $service) {
    return MyContainer::resolveService($service);
});
```

### @error

[](#error)

Allwos you to provide how the `@error` directive should work.

Your callback should return the first error string or `false`:

```
$blade->setErrorHandler(function(string $key) {
    return MyErrorBag::getErrorMessageFor($key);
});
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~212 days

Recently: every ~320 days

Total

8

Last Release

763d ago

Major Versions

1.0.0 → 7.x-dev2020-08-12

6.x-dev → 8.83.102022-05-17

8.83.27 → 9.52.162024-04-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3481634?v=4)[jake whiteley](/maintainers/JakeWhiteley)[@jakewhiteley](https://github.com/jakewhiteley)

---

Top Contributors

[![jakewhiteley](https://avatars.githubusercontent.com/u/3481634?v=4)](https://github.com/jakewhiteley "jakewhiteley (45 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jakewhiteley-bladezero/health.svg)

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

###  Alternatives

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[illuminate/view

The Illuminate View package.

13144.9M1.7k](/packages/illuminate-view)[friendsoftwig/twigcs

Checkstyle automation for Twig

3586.1M61](/packages/friendsoftwig-twigcs)[phlak/directory-lister

PHP directory lister

2.5k1.4k](/packages/phlak-directory-lister)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)

PHPackages © 2026

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