PHPackages                             danilovl/render-service-twig-extension-bundle - 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. danilovl/render-service-twig-extension-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

danilovl/render-service-twig-extension-bundle
=============================================

Symfony twig extension bundle provides rendering service method

v5.0.0(3mo ago)0642MITPHPPHP ^8.5

Since Jan 4Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/danilovl/render-service-twig-extension-bundle)[ Packagist](https://packagist.org/packages/danilovl/render-service-twig-extension-bundle)[ RSS](/packages/danilovl-render-service-twig-extension-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (36)Used By (0)

[![phpunit](https://github.com/danilovl/render-service-twig-extension-bundle/actions/workflows/phpunit.yml/badge.svg)](https://github.com/danilovl/render-service-twig-extension-bundle/actions/workflows/phpunit.yml)[![downloads](https://camo.githubusercontent.com/e6851ac9af6a52efcb2b602b906f4f2fb39440c7a44af50d785e0d4d0cc3e25f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e696c6f766c2f72656e6465722d736572766963652d747769672d657874656e73696f6e2d62756e646c65)](https://packagist.org/packages/danilovl/render-service-twig-extension-bundle)[![latest Stable Version](https://camo.githubusercontent.com/263fbd48558d4ecdb5021a2338d10f89affc853e086800940d72d8c2155e55e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e696c6f766c2f72656e6465722d736572766963652d747769672d657874656e73696f6e2d62756e646c65)](https://packagist.org/packages/danilovl/render-service-twig-extension-bundle)[![license](https://camo.githubusercontent.com/a9d4b623031f209f603ee6bd22b8b55d853614d06379bfcc1429123aee66d8f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e696c6f766c2f72656e6465722d736572766963652d747769672d657874656e73696f6e2d62756e646c65)](https://packagist.org/packages/danilovl/render-service-twig-extension-bundle)

RenderServiceTwigExtensionBundle
================================

[](#renderservicetwigextensionbundle)

About
-----

[](#about)

The Symfony Twig Extension Bundle provides an easy way to create functions or filters from service methods or objects.

The main purpose of this extension is to replace the existing Twig `render(controller())` method.

The main disadvantage of the existing method is that it performs a sub-request, which increases the total execution time of the query.

Comparison performance metrics
------------------------------

[](#comparison-performance-metrics)

In this example, the same page is used, with the only difference being the number of times the standard `render(controller())` method is called compared to the new runtime Twig function.

On the left side, the standard Twig function is used, while on the right side, the runtime Twig function is applied.

Render three times.

[![Alt text](/.github/readme/example-1.png?raw=true "First example")](/.github/readme/example-1.png?raw=true)

Render ten times.

[![Alt text](/.github/readme/example-2.png?raw=true "Second example")](/.github/readme/example-2.png?raw=true)

### Requirements

[](#requirements)

- PHP 8.5 or higher
- Symfony 8.0 or higher

### 1. Installation

[](#1-installation)

Install `danilovl/render-service-twig-extension-bundle` package by Composer:

```
composer require danilovl/render-service-twig-extension-bundle
```

Add the `RenderServiceTwigExtensionBundle` to your application's bundles if it is not added automatically:

```
