PHPackages                             beastbytes/latte-use-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. [Templating &amp; Views](/categories/templating)
4. /
5. beastbytes/latte-use-extension

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

beastbytes/latte-use-extension
==============================

Latte Use Statement Extension

06PHP

Since Dec 7Pushed 5mo agoCompare

[ Source](https://github.com/beastbytes/latte-use-extension)[ Packagist](https://packagist.org/packages/beastbytes/latte-use-extension)[ RSS](/packages/beastbytes-latte-use-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

This package is a [Latte](https://latte.nette.org/) template engine extension that emulates [PHP's `use` operator](https://www.php.net/manual/en/language.namespaces.importing.php)and allows writing cleaner templates.

By default, Latte templates require the use of Fully Qualified CLass Names (FQCN); this can lead to cluttered templates. The extension defines the `{use}` tag that allows templates to define the FQCN and optionally an alias, and refer to the *used* class by the alias if defined, or the base class name if not.

Requirements
------------

[](#requirements)

- PHP 8.1 or higher.
- Latte

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

[](#installation)

Install the package using [Composer](https://getcomposer.org):

Either:

```
composer require beastbytes/latte-use-extension
```

or add the following to the `require` section of your `composer.json`

```
"beastbytes/latte-use-extension": ""
```

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

[](#configuration)

The extension is added to the Latte Engine using the engine's `addExtension()` method.

```
$engine = new Engine();
$engine->addExtension(new UseExtension());
```

Usage
-----

[](#usage)

The FQCN must be defined in a `{use}` tag before the base class name or alias is referenced in the template. The best way to ensure this is to place `{use}` tags as near to the start of the template as possible.

The extension replaces the alias or base class name defined in the `use` tag with the FQCN in class instantation (`new`) statements and class constants during compilation; it *does not* import or alias the class.

#### Differences from PHP

[](#differences-from-php)

- Group `use` definitions are *not* supported.

#### {use} Tag

[](#use-tag)

```
{use Framework\Module\NamespacedClass}

The value is {(new NamespacedClass)->getValue()}
The constant is {NamespacedClass::CONSTANT}
```

#### {use} Tag with Alias

[](#use-tag-with-alias)

```
{use Framework\Module\Aliased\NamespacedClass as AliasedClass}

The value is {(new AliasedClass)->getValue()}
The constant is {AliasedClass::CONSTANT}
```

#### Multiple {use} Tags

[](#multiple-use-tags)

```
{use Framework\Module\Aliased\NamespacedClass as AliasedClass}
{use Framework\Module\NamespacedClass}

{varType int $arg}
{varType string $testString}

The value is {(new NamespacedClass($arg))->getValue()}
The constant is {NamespacedClass::CONSTANT}
{$testString|replace: AliasedClass::CONSTANT}
```

License
-------

[](#license)

The BeastBytes Latte Use Extension is free software. It is released under the terms of the BSD License. Please see [`LICENSE`](./LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance49

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![beastbytes](https://avatars.githubusercontent.com/u/1470144?v=4)](https://github.com/beastbytes "beastbytes (3 commits)")

### Embed Badge

![Health badge](/badges/beastbytes-latte-use-extension/health.svg)

```
[![Health](https://phpackages.com/badges/beastbytes-latte-use-extension/health.svg)](https://phpackages.com/packages/beastbytes-latte-use-extension)
```

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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