PHPackages                             fortephp/forte - 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. fortephp/forte

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

fortephp/forte
==============

v1.0.4(1w ago)45959↓28.6%12MITPHPPHP ^8.2CI passing

Since Jan 14Pushed 2mo agoCompare

[ Source](https://github.com/fortephp/forte)[ Packagist](https://packagist.org/packages/fortephp/forte)[ GitHub Sponsors](https://github.com/johnathonkoster)[ RSS](/packages/fortephp-forte/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (29)Versions (19)Used By (2)

Forte
=====

[](#forte)

> the ... strongest part of the blade
>
>

Forte is a Laravel Blade parser and AST manipulation library.

Quick Start
-----------

[](#quick-start)

```
use Forte\Facades\Forte;
use Forte\Rewriting\NodePath;

// Parse a Blade template into a document
$doc = Forte::parse('Hello, {{ $name }}!');

// Query with XPath
$divs = $doc->xpath('//div[@class]')->get();

// Rewrite (returns a new document, original is unchanged)
$newDoc = $doc->rewriteWith(function (NodePath $path) {
    if ($path->isTag('div')) {
        $path->removeClass('mt-4');
        $path->addClass('container');
    }
});

echo $newDoc->render(); // Hello, {{ $name }}!
```

Core Features
-------------

[](#core-features)

### Parsing

[](#parsing)

Forte's three-phase pipeline (lexer, tree builder, document) handles valid and malformed input alike, recovering gracefully with diagnostics.

```
$doc = Forte::parse($bladeTemplate);
$doc = Forte::parseFile('resources/views/welcome.blade.php');
```

### Immutable Documents

[](#immutable-documents)

Every mutation returns a new `Document` instance. Safe to hold references, chain transformations, and compare before/after states.

### Tree Traversal and Querying

[](#tree-traversal-and-querying)

Walk the tree, find nodes by predicate, or query with XPath 1.0. Blade constructs map to namespaced elements (`forte:if`, `forte:echo`) for XPath queries.

```
// Walk all nodes
$doc->walk(fn ($node) => /* ... */);

// Find first match
$echo = $doc->find(fn ($n) => $n instanceof EchoNode);

// XPath
$doc->xpath('//forte:if')->get();
```

### Rewriting

[](#rewriting)

The visitor pattern with queued operations prevents excessive intermediate documents. Use `NodePath` for all mutations, including CSS class helpers, attribute manipulation, and structural changes.

```
$doc->rewriteWith(function (NodePath $path) {
    if ($path->isTag('center')) {
        $path->renameTag('div');
        $path->addClass('text-center');
    }
});
```

### Components and Directives

[](#components-and-directives)

First-class support for Blade components (``), slots (``), and all directive types (standalone `@csrf`, blocks `@if...@endif`).

```
$component = $doc->findComponentByName('x-alert');
$directive = $doc->find(fn ($n) => $n->isDirectiveNamed('foreach'));
```

### Node Builders

[](#node-builders)

Construct synthetic nodes for replacements and insertions with a fluent API.

```
use Forte\Rewriting\Builders\Builder;

Builder::element('div')->class('wrapper')->text('Hello');
Builder::directive('if', '($show)');
Builder::echo('$name');
```

To learn more, visit .

License
-------

[](#license)

Forte is free software, released under the MIT license.

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance91

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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 ~17 days

Recently: every ~26 days

Total

10

Last Release

11d ago

Major Versions

v0.4.1 → v1.0.02026-03-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/a83ab8381df8c78dbe4acc582ab8b0c0202dfa5f59a4c837b32d78a2bafc0fe7?d=identicon)[stillat](/maintainers/stillat)

---

Top Contributors

[![JohnathonKoster](https://avatars.githubusercontent.com/u/5232890?v=4)](https://github.com/JohnathonKoster "JohnathonKoster (48 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (1 commits)")

---

Tags

bladelaravellaravelblade parser

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fortephp-forte/health.svg)

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

###  Alternatives

[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725173.2k14](/packages/tallstackui-tallstackui)[blade-ui-kit/blade-icons

A package to easily make use of icons in your Laravel Blade views.

2.5k42.5M403](/packages/blade-ui-kit-blade-icons)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[hasinhayder/tyro-dashboard

Tyro Dashboard - Beautiful admin dashboard for managing Tyro roles, privileges, users, and settings

5443.8k](/packages/hasinhayder-tyro-dashboard)

PHPackages © 2026

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