PHPackages                             alexmasterov/twig-extension - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. alexmasterov/twig-extension

ActiveLibrary[HTTP &amp; Networking](/categories/http)

alexmasterov/twig-extension
===========================

A collection of custom extensions for the Twig template engine

0.4.0(9y ago)076MITPHPPHP ^5.4 || ^7.0

Since Apr 17Pushed 9y agoCompare

[ Source](https://github.com/AlexMasterov/twig-extension)[ Packagist](https://packagist.org/packages/alexmasterov/twig-extension)[ Docs](https://github.com/AlexMasterov/twig-extension)[ RSS](/packages/alexmasterov-twig-extension/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Twig Extension(s)
-----------------

[](#twig-extensions)

[![Latest Stable Version](https://camo.githubusercontent.com/2393842826e1c11f699088ce9da6bfd7ac02430c6012d56d1d73bb7d298596fd/68747470733a2f2f706f7365722e707567782e6f72672f616c65786d61737465726f762f747769672d657874656e73696f6e2f762f737461626c65)](https://packagist.org/packages/alexmasterov/twig-extension)[![License](https://camo.githubusercontent.com/79262e824408561f52791176c2d3fe6abbbb77279eaea7a999e34b75b5b2d616/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c65786d61737465726f762f747769672d657874656e73696f6e2e737667)](https://github.com/AlexMasterov/twig-extension/blob/master/LICENSE)[![Build Status](https://camo.githubusercontent.com/61247aee8b6fd1b0a22a02aaaa02a515e1ccee9b9acc5f86a666018fb02ac32a/68747470733a2f2f7472617669732d63692e6f72672f416c65784d61737465726f762f747769672d657874656e73696f6e2e737667)](https://travis-ci.org/AlexMasterov/twig-extension)[![Code Coverage](https://camo.githubusercontent.com/31c1024f55da3176f7d4c2340c6104733e9e2cfd48f6544bdae33c0bba8a2d6f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c65784d61737465726f762f747769672d657874656e73696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AlexMasterov/twig-extension/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/550d72b33713dd2b09812acf6795d6eff305804174e3e38d184add8baf11ebab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f416c65784d61737465726f762f747769672d657874656e73696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/AlexMasterov/twig-extension/?branch=master)

A collection of custom extensions for the [Twig template engine](http://twig.sensiolabs.org/).

Extensions
----------

[](#extensions)

[`Psr7UriExtension`](https://github.com/AlexMasterov/twig-extension/blob/master/src/Psr7UriExtension.php) — provides useful functions using [PSR-7 HTTP message interface](http://www.php-fig.org/psr/psr-7/).

FunctionDescription`absolute_url`Generate an absolute URL for the given absolute or relative path`relative_path`Generate a relative path based on the current path of the URIInstallation
------------

[](#installation)

The suggested installation method is via [composer](https://getcomposer.org/):

```
composer require alexmasterov/twig-extension
```

Configuration
-------------

[](#configuration)

To activate an extension you need to register it into the Twig environment:

```
/*
* @var $twig    Twig_Environment
* @var $request ServerRequestInterface
*/
$twig->addExtension(
    new AlexMasterov\TwigExtension\Psr7UriExtension(ServerRequestInterface $request)
);
```

The example of registering the extension using [Auryn](https://github.com/rdlowrey/auryn) and [Diactoros](https://github.com/zendframework/zend-diactoros):

```
$injector = new Auryn\Injector;
$injector->alias(
    Psr\Http\Message\ServerRequestInterface::class,
    Zend\Diactoros\ServerRequest::class
);

/*
* @var $twig Twig_Environment
*/
$twig->addExtension(
    $injector->make(AlexMasterov\TwigExtension\Psr7UriExtension::class)
);
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Total

4

Last Release

3565d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c3a759788edb549b16d53cc92214268ed89b6dbaa8dfa7025c3b5389bd34edf?d=identicon)[AlexMasterov](/maintainers/AlexMasterov)

---

Top Contributors

[![AlexMasterov](https://avatars.githubusercontent.com/u/700213?v=4)](https://github.com/AlexMasterov "AlexMasterov (21 commits)")

---

Tags

twigtwig-extensionpsr-7twigextension

### Embed Badge

![Health badge](/badges/alexmasterov-twig-extension/health.svg)

```
[![Health](https://phpackages.com/badges/alexmasterov-twig-extension/health.svg)](https://phpackages.com/packages/alexmasterov-twig-extension)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.1B3.8k](/packages/guzzlehttp-psr7)[symfony/psr-http-message-bridge

PSR HTTP message bridge

1.3k312.3M931](/packages/symfony-psr-http-message-bridge)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28146.3k](/packages/phpro-http-tools)[mezzio/mezzio-authentication-oauth2

OAuth2 (server) authentication middleware for Mezzio and PSR-7 applications.

28545.4k3](/packages/mezzio-mezzio-authentication-oauth2)

PHPackages © 2026

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