PHPackages                             mbaynton/csv4twig - 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. mbaynton/csv4twig

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

mbaynton/csv4twig
=================

A CSV escaping filter for the Twig templating engine.

1.0.1(9y ago)19.7k↑300%1[1 issues](https://github.com/mbaynton/csv4twig/issues)MITPHPPHP &gt;=5.4.0

Since Oct 20Pushed 9y agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

CSV4Twig
========

[](#csv4twig)

CSV escaping filter for the Twig templating engine
--------------------------------------------------

[](#csv-escaping-filter-for-the-twig-templating-engine)

[![Build Status](https://camo.githubusercontent.com/6634509b649b0e83b2f35fd05db66add69d5a65a5b423521b4b092e98fe861f7/68747470733a2f2f7472617669732d63692e6f72672f6d6261796e746f6e2f63737634747769672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mbaynton/csv4twig)

CSV4Twig enables Twig templates to generate safe, properly-escaped CSV output. It's useful when you need to get CSV reports out of an existing application that has a Twig-enabled output layer.

### Usage

[](#usage)

1. Add it to your project with composer:
    `composer require mbaynton/csv4twig:1.0.*`
2. Tell Twig about it. You'll need to get a hold of the `\Twig_Environment` instance that will generate the CSV; then just pass it to `\mbaynton\CSV4Twig\Filter::registerFilters()`.
3. Use it in your template with the autoescape tag:

    ```
    {% autoescape "csv" %}
    {{ some_value }},{{ another_value }}
    {% endautoescape %}

    ```

    The contents of `some_value` and `another_value` will be escaped using the default CSV-escaping conventions of PHP's `fputcsv()` function. `fputcsv()` is the function this filter uses internally.

    If you prefer, you can also escape certain values explicitly:

    ```
    {% autoescape false %}
    {{ some_value|e("csv") }},{{ another_value }}
    {% endautoescape %}

    ```

That's it!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3487d ago

### Community

Maintainers

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

---

Top Contributors

[![mbaynton](https://avatars.githubusercontent.com/u/3026002?v=4)](https://github.com/mbaynton "mbaynton (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mbaynton-csv4twig/health.svg)

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M290](/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)[symfony/ux-icons

Renders local and remote SVG icons in your Twig templates.

545.8M69](/packages/symfony-ux-icons)

PHPackages © 2026

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