PHPackages                             sinasalek/twigged-swiftmessage-service-provider - 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. sinasalek/twigged-swiftmessage-service-provider

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

sinasalek/twigged-swiftmessage-service-provider
===============================================

Twig templated Swift\_Message builder service provider for the Silex microframework.

05PHP

Since Dec 19Pushed 11y ago1 watchersCompare

[ Source](https://github.com/sinasalek/TwiggedSwiftMessageServiceProvider)[ Packagist](https://packagist.org/packages/sinasalek/twigged-swiftmessage-service-provider)[ RSS](/packages/sinasalek-twigged-swiftmessage-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

TwiggedSwiftMessageServiceProvider
==================================

[](#twiggedswiftmessageserviceprovider)

[![Build Status](https://camo.githubusercontent.com/1a9a841f2bc97720dbf909875288eab2571f3486eb4a94e5278490b0184d0aaf/68747470733a2f2f7472617669732d63692e6f72672f71636b616e656d6f746f2f5477696767656453776966744d6573736167655365727669636550726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/qckanemoto/TwiggedSwiftMessageServiceProvider)[![Latest Stable Version](https://camo.githubusercontent.com/0d76e7e76ef87a834e376230e9e418b2f7ab507e79f7186583a81a58b7195d76/68747470733a2f2f706f7365722e707567782e6f72672f71636b616e656d6f746f2f747769676765642d73776966746d6573736167652d736572766963652d70726f76696465722f762f737461626c652e737667)](https://packagist.org/packages/qckanemoto/twigged-swiftmessage-service-provider)[![Total Downloads](https://camo.githubusercontent.com/eaac04be61e54ed884c72f736bc595149fdab1c5d0b8edf215aadb3972284b29/68747470733a2f2f706f7365722e707567782e6f72672f71636b616e656d6f746f2f747769676765642d73776966746d6573736167652d736572766963652d70726f76696465722f646f776e6c6f6164732e737667)](https://packagist.org/packages/qckanemoto/twigged-swiftmessage-service-provider)

This is a service provider of [TwiggedSwiftMessageBuilder](https://github.com/qckanemoto/TwiggedSwiftMessageBuilder) for [Silex](http://silex.sensiolabs.org/).

Requirements
------------

[](#requirements)

- PHP 5.3+

Getting started
---------------

[](#getting-started)

First add this dependency into your `composer.json`:

```
{
    "require": {
        "qckanemoto/twigged-swiftmessage-service-provider": "1.0.*@dev"
    },
    "minimum-stability": "dev"
}
```

And enable this service provider in your application. Please notice that you must register both `TwigServiceProvider` and `SwiftmailerServiceProvider` on ahead.

```
$app->register(new TwigServiceProvider());
$app->register(new SwiftmailerServiceProvider());
$app->register(new \Qck\Silex\Provider\TwiggedSwiftMessageServiceProvider());
```

Then you can build `Swift_Message` object via twig template.

```
$message = $app['twigged_message']->buildMessage('email.txt.twig');
$message->setTo('hoge@example.com');
$app['mailer']->send($message);
```

See more detailed documentation [here](https://github.com/qckanemoto/TwiggedSwiftMessageBuilder/blob/master/README.md).

Use submitted form data in Twig template
----------------------------------------

[](#use-submitted-form-data-in-twig-template)

This service provider provides one additional feature to use submitted form data in Twig template easily. `$app['twigged_swiftmessage.form_handler']` allows you to extract data array from `Form` object.

Labels and values of each fields can be used as below:

- `{{ form.[field-name].label }}`
- `{{ form.[field-name].value }}`

For example:

```
{# email.txt.twig #}

{% block from %}{{ form.email.value }}{% endblock %}
{% block from_name %}{{ form.name.value }}{% endblock %}
{% block to %}contact@example.com{% endblock %}

{% block subject %}[Contact] {{ form.summary.value }}{% endblock %}

{% block body %}
{% for item in form %}
----------------------------------------------------------------------
{{ item.label }}: {{ item.value }}
{% endfor %}
----------------------------------------------------------------------
{% endblock %}
```

```
// in your controller.

$form->handleRequest($request);
if ($form->isValid()) {
    $array = $app['twigged_message.form_handler']->getDataArray($form);
    $message = $app['twigged_message']->buildMessage('email.txt.twig', array('form' => $array));
    $app['mailer']->send($message);
}
```

Offcourse you also can access to your custom field type as below:

- `{{ form.[parent-field].[child-field].label }}`
- `{{ form.[parent-field].[child-field].value }}`

Enjoy!
------

[](#enjoy)

See more detailed documentation [here](https://github.com/qckanemoto/TwiggedSwiftMessageBuilder/blob/master/README.md).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/571bc5d492f577748449e5624607338f321e59571a60043b65970f4129def671?d=identicon)[sinasalek](/maintainers/sinasalek)

---

Top Contributors

[![sinasalek](https://avatars.githubusercontent.com/u/592240?v=4)](https://github.com/sinasalek "sinasalek (7 commits)")

### Embed Badge

![Health badge](/badges/sinasalek-twigged-swiftmessage-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/sinasalek-twigged-swiftmessage-service-provider/health.svg)](https://phpackages.com/packages/sinasalek-twigged-swiftmessage-service-provider)
```

###  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)
