PHPackages                             chi-teck/trafaret - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. chi-teck/trafaret

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

chi-teck/trafaret
=================

Trafaret data processor

1.0.0(4y ago)19511MITPHPPHP &gt;=7.3

Since Sep 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Chi-teck/trafaret)[ Packagist](https://packagist.org/packages/chi-teck/trafaret)[ RSS](/packages/chi-teck-trafaret/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (7)Used By (1)

Trafaret
========

[](#trafaret)

[![Build Status](https://github.com/Chi-teck/trafaret/workflows/Tests/badge.svg)](https://github.com/Chi-teck/trafaret/workflows/Tests/badge.svg)

A simple way to extract data from multiline textual snippets.

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

[](#installation)

`composer require chi-teck/trafaret --dev`

Usage
-----

[](#usage)

```
$input =  new GreaterThan(10),
    ],
);

$manager = Manager::createDefault();

try {
    $data = $manager->apply($trafaret, $input);
}
catch (ExceptionInterface $exception) {
    \file_put_contents('php://stderr', $exception->getMessage() . "\n");
    exit(1);
}

print_r($data);
```

Placeholders are validated using [Symfony Validator](https://symfony.com/doc/current/components/validator.html).

For tests based on PHPUnit you can make use of TrafaretTrait to validate markup as shown below.

```
final class HomePageTest extends SiteTestCase
{
    use TrafaretTrait;

    public function testMarkup(): void
    {
        $trafaret = Trafaret::createFromFile(__DIR__ . '/../fixtures/home-page.html.trf');
        $actual_html = $this->findByXpath('//div[@class = "page"]')->getOuterHtml();
        $this->assertStringByTrafaret($trafaret, $actual_html);
    }
}
```

License
-------

[](#license)

MIT License

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

Recently: every ~133 days

Total

6

Last Release

1588d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/673139?v=4)[Ivan](/maintainers/chi-teck)[@Chi-teck](https://github.com/Chi-teck)

---

Top Contributors

[![Chi-teck](https://avatars.githubusercontent.com/u/673139?v=4)](https://github.com/Chi-teck "Chi-teck (47 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/chi-teck-trafaret/health.svg)

```
[![Health](https://phpackages.com/badges/chi-teck-trafaret/health.svg)](https://phpackages.com/packages/chi-teck-trafaret)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M337](/packages/api-platform-core)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.5k10](/packages/helsingborg-stad-municipio)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[api-platform/serializer

API Platform core Serializer

274.8M85](/packages/api-platform-serializer)[api-platform/validator

API Platform validator component

274.6M27](/packages/api-platform-validator)

PHPackages © 2026

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