PHPackages                             fhooe/twig-extensions - 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. fhooe/twig-extensions

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

fhooe/twig-extensions
=====================

A collection of Twig extensions for other fhooe packages

v3.0.0(1mo ago)05901MITPHPPHP ^8.5

Since Feb 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Digital-Media/fhooe-twig-extensions)[ Packagist](https://packagist.org/packages/fhooe/twig-extensions)[ RSS](/packages/fhooe-twig-extensions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (1)

fhooe/twig-extensions
=====================

[](#fhooetwig-extensions)

A collection of Twig extensions for other *fhooe* packages used in the [Media Technology and Design](https://fh-ooe.at/en/degree-programs/media-technology-and-design-bachelor) program at the [University of Applied Sciences Upper Austria](https://fh-ooe.at/en/campus-hagenberg). It is intended to be used with packages such as [*fhooe/router*](https://github.com/Digital-Media/fhooe-router) or [*fhooe/router-skeleton*](https://github.com/Digital-Media/fhooe-router-skeleton), respectively.

Installation
------------

[](#installation)

Integrate the package into your project using [Composer](https://getcomposer.org/):

```
composer require fhooe/twig-extensions
```

Contents
--------

[](#contents)

This package contains the following extensions:

### `RouterExtension`

[](#routerextension)

An extension to access the *fhooe/router* package from within Twig templates. It provides the following functions:

- `url_for("/some/route")`: Returns the full URL for the given route.
- `get_base_path()`: Returns the base path if the application is not in the server's document root.

### `SessionExtension`

[](#sessionextension)

Provides the function `session("someKey")`, which returns the value of the given key in the session. That way, not every needed entry in `$_SESSION` (or even the whole superglobal) must be passed to the template.

Usage
-----

[](#usage)

Register the extensions with your Twig environment, then use the provided functions in your templates:

### `RouterExtension`

[](#routerextension-1)

Register the extension and provide an instance of `Fhooe\Router\Router`.

```
$twig->addExtension(new Fhooe\Twig\RouterExtension(new Fhooe\Router\Router()));
```

Use the functions:

```
{{ url_for("/some/route") }}
{{ get_base_path() }}
```

This will output the full path for the route or a base path (if you need to prefix) static paths for stylesheets or other files.

### `SessionExtension`

[](#sessionextension-1)

Register the extension:

```
$twig->addExtension(new Fhooe\Twig\SessionExtension());
```

Use the function:

```
{{ session("someKey") }}
```

This will output the value of `$_SESSION["someKey"]`. If nothing is stored under that key, sessions are inactive, or the session superglobal is unavailable, an empty string will be returned so that you can use the function safely.

Contributing
------------

[](#contributing)

If you'd like to contribute, please refer to [CONTRIBUTING](https://github.com/Digital-Media/fhooe-twig-extensions/blob/main/CONTRIBUTING.md) for details.

License
-------

[](#license)

*fhooe/twig-extensions* is licensed under the MIT license. See [LICENSE](https://github.com/Digital-Media/fhooe-twig-extensions/blob/main/LICENSE) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

3

Last Release

53d ago

Major Versions

v1.0.0 → v2.0.02025-03-26

v2.0.0 → v3.0.02026-03-24

PHP version history (3 changes)v1.0.0PHP ^8.3

v2.0.0PHP ^8.4

v3.0.0PHP ^8.5

### Community

Maintainers

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

---

Top Contributors

[![hochleitner](https://avatars.githubusercontent.com/u/2236807?v=4)](https://github.com/hochleitner "hochleitner (34 commits)")

---

Tags

twigroutingextensionssessionseducation

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fhooe-twig-extensions/health.svg)

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

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36663.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

21946.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

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