emodric/twig-package-versions

Twig functions that return a package version by using jean85/pretty-package-versions library

Maintainers

๐Ÿ‘ emodric

Package info

github.com/emodric/twig-package-versions

Homepage

pkg:composer/emodric/twig-package-versions

Statistics

Installs: 112โ€‰390

Dependents: 2

Suggesters: 0

Stars: 6

Open Issues: 0

2.0.0 2025-12-30 17:00 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT c7d66966f5e6ea027e871a17ac17ead14ae3c1e5

templatingsymfonypackagetwigversion

This package is auto-updated.

Last update: 2026-06-29 00:52:59 UTC


README

This package provides simple Twig functions that wrap PrettyPackageVersions lib by Alessandro Lai making it possible to output version strings of your libraries directly inside your Twig templates.

Initially, this Twig extension was submitted as a pull request against official Twig Extensions collection, but was turned into a separate package since no new features are accepted over there.

Installation

To install this extension, use Composer:

composer require emodric/twig-package-versions

Using the extension

In PHP:

$twig = new \Twig\Environment($loader, $options);

$twig->addExtension(new \EdiModric\Twig\VersionExtension());

In a Symfony project, you can register the extension as a service:

services:
 twig.extension.version:
 class: EdiModric\Twig\VersionExtension
 tags:
 - { name: twig.extension }

Once set up, you can use the following Twig functions:

  • package_version('my-vendor/package-name') - Returns the full package version string
  • pretty_package_version('my-vendor/package-name') - Returns pretty package version string