PHPackages                             roy404/blades - 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. roy404/blades

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

roy404/blades
=============

A PHP library that provides Blade-like templating functionality, enabling seamless integration of Blade syntax and components.

1.7.9(5mo ago)13152MITPHPPHP ^8.0

Since Jan 13Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/roycanales17/PHP-Blades-Compiler)[ Packagist](https://packagist.org/packages/roy404/blades)[ RSS](/packages/roy404-blades/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (87)Used By (2)

Content - Blades Compiler
=========================

[](#content---blades-compiler)

This library allows you to integrate Blade-like templating functionality into your PHP application. It enables the use of Blade syntax and components, offering a familiar and powerful templating engine for your project.

**Installation**

To get started, install the bundle via Composer:

```
composer require roy404/blades

```

Blades Feature Documentation
============================

[](#blades-feature-documentation)

`Blades` is a PHP library designed to provide Blade-inspired templating capabilities. With this library, you can use Blade syntax and custom directives in your PHP applications, facilitating a smooth transition for developers. The library enhances your templating workflow with custom methods and functionalities that mimic Blade's behavior while offering additional flexibility for use outside the Laravel ecosystem.

Blade Custom Methods Usage Guide
================================

[](#blade-custom-methods-usage-guide)

This guide helps you understand when and how to use the `compile`, `loadDirectives`, and `load` methods in your project.

🧩 1. `loadDirectives()`
-----------------------

[](#-1-loaddirectives)

### 🔍 What It Does

[](#-what-it-does)

- Loads all directive definition files from a given directory.
- Each directive file should define logic extending the compiler.

### ✅ When To Use

[](#-when-to-use)

- You need to register your own custom directives.
- You want to make sure directives are available before calling `compile()`.

Note: You usually don’t need to call this manually — compile() will automatically invoke it if no directives are loaded.

### 🧪 Example

[](#-example)

```
Blade::loadDirectives(__DIR__ . '/directives');
```

🧩 2. `compile()`
----------------

[](#-2-compile)

### 🔍 What It Does

[](#-what-it-does-1)

- Compiles raw template content (as a string).
- Applies all registered compiler instances and directives.
- Returns the final compiled output as a string.

### ✅ When To Use

[](#-when-to-use-1)

- You want to render template content stored in a variable or database.
- You need to manually post-process or store the compiled output.

### 🧪 Example

[](#-example-1)

```
$content = 'Hello, {{ $name }}!';
echo Blade::compile($content, ['name' => 'Robroy Canales']);
```

🧩 3. `load()`
-------------

[](#-3-load)

### 🔍 What It Does

[](#-what-it-does-2)

- Loads and compiles a `.php` (or template) file.
- Renders it directly with the provided variables.

### ✅ When To Use

[](#-when-to-use-2)

- You have a physical file you want to render.
- You want to output the view directly (e.g. from a controller or route handler).

### 🧪 Example

[](#-example-2)

```
Blade::load(__DIR__ . '/views/profile.php', ['user' => $user]);
```

🛠️ 4. `build()`
---------------

[](#️-4-build)

### 🔍 What It Does

[](#-what-it-does-3)

- Initializes a new Blade engine instance using a custom compiler (implementing `ViewsInterface`).
- Returns the instance for chaining, such as registering custom directives.

### ✅ When To Use

[](#-when-to-use-3)

- You want to register **custom directives** to extend the template engine.
- You are implementing your own logic inside a compiler class (like a plugin).

### 🧪 Example

[](#-example-3)

```
Blade::build(new Loops)->register(function (Blade $blade) {
	// Add @break directive
	$blade->directive('break', fn() => '');

	// Add @continue directive
	$blade->directive('continue', fn() => '');
});
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance70

Regular maintenance activity

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~4 days

Total

86

Last Release

173d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/542567e23f273798a0a4a752804c792654fe6c3753b53752b1d00b7eff2b8b11?d=identicon)[roycanales](/maintainers/roycanales)

---

Top Contributors

[![roycanales17](https://avatars.githubusercontent.com/u/62797701?v=4)](https://github.com/roycanales17 "roycanales17 (155 commits)")

---

Tags

blade-compilerblade-directivesblade-syntaxcomponent-based-designhtml-templatesphp-libraryphp-templatingtemplate-engineview-compilerview-componentsphpcompiler

### Embed Badge

![Health badge](/badges/roy404-blades/health.svg)

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

###  Alternatives

[endroid/qr-code-bundle

Endroid QR Code Bundle

32110.6M17](/packages/endroid-qr-code-bundle)[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k13](/packages/phug-phug)

PHPackages © 2026

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