# Zend Expressive with Symfony form and Twig view helpers

**URL:** <https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968>\
**Category:** Mezzio\
**Tags:** twig\
**Created:** [February 28, 2019, 4:42pm UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968 "2019-02-28T16:42:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![open-it](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/open-it/32/304_2.png) [@open-it](https://discourse.laminas.dev/u/open-it)\
**Post date:** [February 28, 2019, 4:42pm UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/1 "2019-02-28T16:42:07Z")

</div>

Hello all,

I’m trying an application with Zend Expressive but I am used to work with Symfony. So I wanted to work with Symfony Form and Twig view helpers (like form\_start, form\_end…).

First I install symfony/form, I can create form. It is a bit more complicated than in Symfony but finaly I can create Form.

In my Twig view, I want to use form\_start, form\_row… It doesn’t work… So I’ve search and install symfony/twig-bridge. I’ave added a little config  
‘dependencies’ =\> [  
‘factories’ =\> [  
TwigExtension::class =\> FormExtension::class,  
]  
]  
then  
class FormExtension  
{  
public function \_\_invoke() : \Twig\_Extension  
{  
$formExtension = new \Symfony\Bridge\Twig\Extension\FormExtension();  
return $formExtension;  
}  
}

but it ends with an error :

```
 Twig_Error_Runtime

```

Unable to load the “Symfony\Component\Form\FormRenderer” runtime.

So now, I don’t really know if it was really a good idea…

I really like Expressive but it seems not so simple to use others libs than Zend.

Does somebody know how to achieve my problem ?

---

<div class="post-metadata">

**Author:** ![harikt](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/harikt/32/47_2.png) [@harikt](https://discourse.laminas.dev/u/harikt)\
**Post date:** [March 2, 2019, 3:20am UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/2 "2019-03-02T03:20:07Z")

</div>

The problem is not at Zend expressive level. Some of the components are tightly bind to the framework. To use symfony I would recommend looking at [https://github.com/webmozart/standalone-forms](https://github.com/webmozart/standalone-forms) . You may want to make certain changes for Zend expressive don’t rely on symfony/request but psr-7 and integration of twig. I hope this will help. iirc there is also integration with slim by akrabat. You may want to search it.

---

<div class="post-metadata">

**Author:** ![open-it](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/open-it/32/304_2.png) [@open-it](https://discourse.laminas.dev/u/open-it)\
**Post date:** [March 3, 2019, 10:04pm UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/3 "2019-03-03T22:04:23Z")

</div>

I m not saying the problem comes from Zend expressive. I m saying it s not as easy as mentioned to use libs that doesn’t come from Zend. Your link talks about Symfony 2.7. The current is 4.3… I will have a look tomorrow anyway. Thanks.

---

<div class="post-metadata">

**Author:** ![Moln](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/moln/32/324_2.png) [@Moln](https://discourse.laminas.dev/u/Moln)\
**Post date:** [March 4, 2019, 12:01am UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/4 "2019-03-04T00:01:00Z")

</div>

The `Twig\Environment` need a `RuntimeLoader` for load `Symfony\Component\Form\FormRenderer`.

---

<div class="post-metadata">

**Author:** ![open-it](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/open-it/32/304_2.png) [@open-it](https://discourse.laminas.dev/u/open-it)\
**Post date:** [March 4, 2019, 6:33am UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/5 "2019-03-04T06:33:43Z")

</div>

Thanks I saw something like this in the code but I was affraid to get lots and lots dependencies, I will try to instanciate this RuntimeLoader and configure it. If it doesn’t work… I’ll give up ☹

---

<div class="post-metadata">

**Author:** ![Moln](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/moln/32/324_2.png) [@Moln](https://discourse.laminas.dev/u/Moln)\
**Post date:** [March 5, 2019, 11:03am UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/6 "2019-03-05T11:03:25Z")

</div>

This is my component of `symfony/twig-bridge` extension factories.

> **[zfegg/symfony-twig-factory](https://github.com/zfegg/symfony-twig-factory)**
>
> Using symfony/twig-bridge in Expressive. (e.g.: asset,workflow) - zfegg/symfony-twig-factory

And this is [example file](https://github.com/zfegg/symfony-twig-factory/blob/master/example/index.php)

---

<div class="post-metadata">

**Author:** ![open-it](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/open-it/32/304_2.png) [@open-it](https://discourse.laminas.dev/u/open-it)\
**Post date:** [March 5, 2019, 1:11pm UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/7 "2019-03-05T13:11:26Z")

</div>

Ohhhhh !!! I will try that ! right NOW ! 👏

---

<div class="post-metadata">

**Author:** ![open-it](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/open-it/32/304_2.png) [@open-it](https://discourse.laminas.dev/u/open-it)\
**Post date:** [March 5, 2019, 2:19pm UTC](https://discourse.laminas.dev/t/zend-expressive-with-symfony-form-and-twig-view-helpers/968/9 "2019-03-05T14:19:21Z")

</div>

Thanks it seems to work. You need to promote your lib @Moln😉
