PHPackages                             tacman/blade-parser - 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. tacman/blade-parser

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

tacman/blade-parser
===================

08PHP

Since May 8Pushed 1y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Standalone Blade Parser and Compiler
====================================

[](#standalone-blade-parser-and-compiler)

This is an experimental Blade parser and compiler. It is able to parse Blade templates, and regenerate them.

Parsing a Blade Document
------------------------

[](#parsing-a-blade-document)

To parse a document, first create an instance of the Blade parser:

```
use Stillat\BladeParser\Parsers\Blade;

$parser = new Blade();
```

Once you have a parser instance, you may use the `parse($input)` method to receive an instance of `Stillat\BladeParser\Documents\Template`:

```
use Stillat\BladeParser\Parsers\Blade;

$parser = new Blade();

$document = $parser->parse('@extends("layout")');
```

The `Template` document instance contains information about the parsed Blade template. To work with the document, you must implement the `Stillat\BladeParser\Visitors\AbstractNodeVisitor` interface:

```
use Stillat\BladeParser\Nodes\Node;
use Stillat\BladeParser\Visitors\AbstractNodeVisitor;

class MyVisitor extends AbstractNodeVisitor
{

    public function onEnter(Node $node)
    {
        echo $node->innerContent;
    }
}
```

Once you have created your visitor, you must ask the document for a `TemplateTraverser` instance, add your new visitor, and then call the `traverse()` method:

```
$traverser = $document->getTraverser();
$traverser->addVisitor(new MyVisitor());

$traverser->traverse();
```

The `onEnter` method within all added traversers will be invoked with the document's nodes.

The built-in `Stillat\BladeParser\Visitors\PrinterNodeVisitor` and the `Stillat\BladeParser\Printers\Php\Printer` demonstrate advanced usage of the traverser mechanisms.

Component Details Resolver
--------------------------

[](#component-details-resolver)

The provided PHP compiler (printer) requires an instance of `Stillat\BladeParser\Contracts\ComponentDetailsResovlerContract`. This interface is responsible for providing information about the component's class name, properties, data, and attributes. This resolver will be environment specific, you may use the mocked test resolver at `tests/AppComponentNameFinder.php` as an example.

Using the Default PHP Compiler
------------------------------

[](#using-the-default-php-compiler)

To compile a Blade document from a collection of previously parsed nodes, you will first need to create an instance of `Stillat\BladeParser\Contracts\ComponentDetailsResovlerContract`. Once you have this interface implemented, you may set up a compiler like so:

```
use Stillat\BladeParser\Compilers\PhpCompiler;

$compiler = new PhpCompiler($yourComponentDetailsResolverInstance);

$compiledString = $compiler->compileString('@extends("some_file")');
```

Known Issues
------------

[](#known-issues)

Not all of the details provided in the `Node` instances are 100% accurate at this time. Pull requests are welcomed!

License
-------

[](#license)

This parser library is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/21b39551f92ed4143772c622f9e571589c5a72c96ab3c53fe67489ce0d83e806?d=identicon)[tacman1123](/maintainers/tacman1123)

---

Top Contributors

[![JohnathonKoster](https://avatars.githubusercontent.com/u/5232890?v=4)](https://github.com/JohnathonKoster "JohnathonKoster (10 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (4 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")

### Embed Badge

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

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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